#include using namespace std; int main(){ ios_base::sync_with_stdio(false); cin.tie(NULL); int n; long long m,p; cin>>n>>m>>p; long long tmp; long long min_a=-1; for(int i=0;i>tmp; if (tmp>m){ min_a=1; }else{ long long cnt=0; while(tmp%p==0){ cnt++; tmp/=p; } if (tmp==1) continue; if(min_a==-1){ min_a=ceil(log(m)/log(tmp))+cnt*(ceil(log(m)/log(tmp))-1); }else{ min_a=min(min_a,(long long)ceil(log(m)/log(tmp))+cnt*((long long)ceil(log(m)/log(tmp))-1)); } } } cout<