import java.io.*; import java.util.*; public class Solution { public static void main(String[] args) { Scanner sc=new Scanner(System.in); int n=sc.nextInt(); int m=sc.nextInt(); int cut=0; if(m>n&&m>1) { if(n==1) { while(m>1) { cut++; m--; } } else { while(n>1) { cut++; n--; } while(m>1) { cut++; m--; } } } else if(n>m&&n>1) { if(m==1) { while(n>1) { cut++; n--; } } else { while(n>1) { cut++; n--; } while(m>1) { cut++; m--; } } } else { } System.out.println(cut); } }