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 in = new Scanner(System.in); int n = in.nextInt(); int m = in.nextInt(); int cuts = cut(n, m); System.out.printf("%d", cuts); } public static int cut(int n, int m) { if (n == 1 && m == 1) { return 0; } else if (n == 1 && m > 1) { return 1 + cut(1, m - 1); } else if (n > 1 && m == 1) { return 1 + cut(n - 1, 1); } else if (n > m) { return 1 + cut(n, 1) + cut(n, m - 1); } else { return 1 + cut(1, m) + cut(n - 1, m); } } }