#include using namespace std; int get_ceil(long long m,long long tmp){ int ans=1; long long cur=tmp; while(cur>n>>m>>p; long long tmp; long long min_a=-1; for(int i=0;i>tmp; long long tmp2=tmp; if (tmp>m){ min_a=1; }else{ long long cnt=0; while(tmp%p==0){ cnt++; tmp/=p; } if (tmp==1) continue; int ttt; if(m%tmp2==0) ttt=get_ceil(m/tmp2,tmp); else ttt=get_ceil(m/tmp2+1,tmp); if(min_a==-1){ min_a=ttt+cnt*(ttt-1)+1; }else{ min_a=min(min_a,ttt+cnt*(ttt-1)+1); } } } cout<