#include #include #include #include #include using namespace std; long long cuts(int n, int m) { if (n == 1 && m == 1) return 0; if (n == 1) return m - 1; if (m == 1) return n - 1; if (m > n) { return (m - 1) + m * cuts(n, 1); } else { return (n - 1) + n * cuts(1, m); } } int main() { /* Enter your code here. Read input from STDIN. Print output to STDOUT */ int n, m; cin >> n >> m; cout << cuts(n, m) << endl; return 0; }