import java.io.*; import java.util.*; public class Solution { public static void main(String[] args) { /* Enter your code here. Read input from STDIN. Print output to STDOUT. Your class should be named Solution. */ Scanner scan = new Scanner(System.in); int m = scan.nextInt(); int n = scan.nextInt(); scan.close(); System.out.println(minCuts(m, n)); } public static int minCuts(int m, int n) { if (m <= 1 && n <= 1) return 0; int cuts = 1; int big = 0; int small = 0; if (m > n) { big = m; small = n; } else { big = n; small = n; } // cut along m if ((big & 1) > 0) { // it is odd cuts += minCuts(big/2, small); cuts += minCuts(big/2+1, small); } else { // it is even cuts += minCuts(big/2, small) * 2; } return cuts; } }