#include #include #include #include #include using namespace std; struct mn { int_fast32_t m, n; bool operator<(const mn& other) const { if (m < other.m) return true; return n < other.n; } }; static map mnmap; int_fast32_t cuts(int_fast32_t m, int_fast32_t n) { if (m > n) return cuts(n, m); auto it = mnmap.find({m, n}); if (it != mnmap.end()) return it->second; if (m == 1 && n == 1) return 0; int_fast32_t retval = 1; if (n % 2 == 0) retval += 2 * cuts(m, n / 2); else retval += cuts(m, n / 2) + cuts(m, n / 2 + 1); mnmap[{m ,n}] = retval; return retval; } int main() { int_fast32_t m, n; cin >> n >> m; cin.ignore(); cout << cuts(m, n) << endl; return 0; }