#include long long N; long long a[1000],b[1000]; long long i,s,t,u,v,ans; long long min(long long a, long long b){ if(a>b){return b;}else{return a;} } long long max(long long a, long long b){ if(a>b){return a;}else{return b;} } long long ugly(long long x){ long long mi,ma; mi = 1000000000000000000; ma = 0; for(i=0;i2){ u = (2*s + t)/3; v = (s + 2*t)/3; if(ugly(u)<=ugly(v)){t = v;}else{s = u;} } if(ugly(s)<=ugly(s+1) && ugly(s)<=ugly(s+2)){ans = s;} else if(ugly(s+1)<=ugly(s) && ugly(s+1)<=ugly(s+2)){ans = s+1;} else{ans = s+2;} printf("%I64d\n",ans); }