<Problem>
http://ntucoder.net/Problem/Details/3346
USES CRT;
var NT:array[1..5000000] of boolean;
a,b,i,dem:longint;
PROCEDURE ERAS;
var i,temp1:longint;
begin
fillchar(NT,sizeof(NT),true);
for i:=2 to 316 do
if NT[i]=true then begin
temp1:=i;
while temp1<=100000 do begin
inc(temp1,i);
NT[temp1]:=false;
end;
end;
end;
FUNCTION PALIN (n:longint):boolean;
var i:longint;
s:string;
begin
str(n,s);
for i:=1 to length(s) do
if s[i]<>s[length(s)-i+1] then exit(false);
exit(true);
end;
begin
ERAS;
readln(a,b);
dem:=0;
for i:=a to b do
if (NT[i]) and (PALIN(i)) then inc(dem);
writeln(dem);
readln
end.