uses crt;
var n,m,i,j:Longint; k:qword;
a,b:string;
function nt(a:qword):boolean;
var i:qword;
begin
i:=2;
while a mod i<>0 do inc(i);
nt:=i=a;
end;
begin
clrscr;
write('n=');readln(n);
i:=1;
repeat
inc(i);
if nt(I) then
begin
j:=i+1;
while not(nt(j)) do inc(j);
str(i,a); str(j,b);
val(a+b,k); if (nt(k))and(nt(i)) then inc(m);
end;
until m=n;
writeln(K);
readln
end.