#include using namespace std; using Int = long long; template inline void chmin(T1 &a,T2 b){if(a>b) a=b;} template inline void chmax(T1 &a,T2 b){if(a=w){ ans+=(h-(w-1)); h=w-1; } for(Int i=1;i<=h;i<<=1){ Int j=min((i<<1)-1,h); Int len=j-i+1; ans+=len*(w/i); Int res=w%i; ans+=res; } return ans; } Int solve3(Int h,Int w){ vector cnt(w+1,0); cnt[0]=h; map, Int> dp; queue< vector > que; dp[cnt]=0; que.emplace(cnt); auto start=clock(); while(!que.empty()){ if((double)(clock()-start)/CLOCKS_PER_SEC>=3.0) break; cnt=que.front();que.pop(); for(Int i=0;i nxt=cnt; nxt[i]--; nxt[j]++; if(dp.count(nxt)) continue; dp[nxt]=dp[cnt]+1; que.emplace(nxt); } break; } } cnt.assign(w+1,0); cnt[w]=h; return dp[cnt]; } signed main(){ Int h,w; cin>>h>>w; cout<