var a,f:array[0..1001000]of longint;
b:array[0..1001000]of boolean;
l,r,p,i,n,j,t:longint;
procedure init;
begin
readln(l,r,p); n:=0;
for i:=1 to r do f[i]:=i;
end;
procedure deal;
begin
for i:=2 to r do if not b[i] then
begin
j:=i; inc(n); a[n]:=i;
while j+i<=r do
begin
j:=j+i;
b[j]:=true;
end;
end;
end;
function find(k:longint):longint;
begin
if f[k]=k then exit(k);
f[k]:=find(f[k]); exit(f[k]);
end;
procedure work;
begin
deal; j:=1; while (a[j]<p)and(j<=n) do inc(j);
for i:=j to n do
begin
t:=a[i]; while t<l do t:=t+a[i];
while t+a[i]<=r do
begin
f[find(t)]:=find(t+a[i]);
t:=t+a[i];
end;
end;
fillchar(b,sizeof(b),0); n:=0;
for i:=l to r do b[find(i)]:=true;
for i:=1 to r do if b[i] then inc(n);
writeln(n);
end;
begin
assign(input,'setb.in');reset(input);
assign(output,'setb.out');rewrite(output);
init;
work;
close(input); close(output);
end.