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