#include #define ll long long int #define F first #define S second #define PB push_back #define MP make_pair using namespace std; map,ll > ans; ll doit(ll n,ll m){ if(ans[MP(n,m)]!=0)return ans[MP(n,m)]; if(n==1&&m==1)return 0; else if(n==1)return m-1; else if(m==1)return n-1; else{ ll x1,y1; if((n%2)==0)x1 = 2*doit(n/2,m)+1; else x1 = doit(n/2,m)+doit(n-n/2,m)+1; if((m%2)==0)y1 = 2*doit(n,m/2)+1; else y1 = doit(n,m/2)+doit(n,m-m/2)+1; ans[MP(n,m)]= min(x1,y1); ans[MP(m,n)]= min(x1,y1); return min(x1,y1); } } int main(){ ll n,m; cin>>n>>m; cout<