program setb;
var a,b,p,i,j,n,t:longword;
s:array[1..10000]of longword;
w:array[1..100000]of boolean;
ok:boolean;
function su(k:longword):boolean;
var i:integer;
begin
if k=2 then exit(true);
for i:=2 to trunc(sqrt(k)) do if k mod i = 0 then exit(false);
exit(true);
end;
begin
assign(input,'setb.in'); reset(input);
assign(output,'setb.out'); rewrite(output);
fillchar(w,sizeof(w),false); n:=0;
readln(a,b,p);
for i:=a to b do w[i]:=true;
for i:=p to b do if su(i) then begin inc(n); s[n]:=i; end;
t:=0;
for i:=n downto 1 do
begin
ok:=false; j:=a;
if j mod s[i]<>0 then j:=(a div s[i])*s[i]+s[i];
repeat
if (j<=b)and(w[j])and(j mod s[i]=0)
then begin
w[j]:=false;
ok:=true;
end;
inc(j,s[i]);
until j>=b;
if ok then inc(t);
end;
writeln(t);
close(input); close(output);
end.