/**
A. Music
*/
#include<algorithm>
#include<iostream>
#include<cstring>
#include<cstdio>
#define maxn 100005
using namespace std;
int main(){
int n,m,q;
while(cin>>n>>m>>q){
int ans=0;
while(m<n){
m+=(q-1)*m;
ans++;
}
printf("%d\n",ans);
}
return 0;
}
/**
B. Inventory
*/
#include<algorithm>
#include<iostream>
#include<cstring>
#include<cstdio>
#define maxn 100005
using namespace std;
int a[maxn];
int ans[maxn];
bool b[maxn];
int main(){
int n;
while(~scanf("%d",&n)){
memset(b,0,sizeof(b));
memset(ans,0,sizeof(ans));
for(int i=0;i<n;i++){
scanf("%d",&a[i]);
if(!b[a[i]]&&a[i]<=n)
ans[i]=a[i];
b[a[i]]=true;
}
int A=1;
for(int i=0;i<n;i++){
if(ans[i]) continue;
while(b[A]) A++;
ans[i]=A++;
}
for(int i=0;i<n;i++){
if(i==0) printf("%d",ans[i]);
else printf(" %d",ans[i]);
}
printf("\n");
}
return 0;
}
</pre><pre name="code" class="cpp">/**
C. Primes or Palindromes?
*/
#include<algorithm>
#include<iostream>
#include<cstring>
#include<cstdio>
#define maxn 1200005
#define ret 1.0*pr[i]/pa[i]
using namespace std;
int a[10];
bool check(int num){//判断回文数
int A=0;
while(num){
a[A++]=num%10;
num/=10;
}
for(int i=0;i<A/2;i++)
if(a[i]!=a[A-i-1]) return false;
return true;
}
int pa[maxn]={0};
int pr[maxn]={0};
bool b[maxn]={0};
void Init(){
for(int i=2;i*i<=maxn-5;i++){
if(!b[i]);
for(int j=i+i;j<=maxn-5;j+=i)
b[j]=true;
}
pa[1]=1;
for(int i=2;i<=maxn-5;i++){
pa[i]=pa[i-1]+check(i);
pr[i]=pr[i-1]+(!b[i]);
}
}
int main(){
Init();
double p,q;
while(cin>>p>>q){
p/=q;
int ans=1;
for(int i=2;i<=maxn-5;i++)//暴力求解
if(ret<=p) ans=i;
printf("%d\n",ans);
}
return 0;
}