uses crt;
function Prost(n:longint):boolean;
var i:longint;
begin
Prost:=true;
for i:=2 to round(sqrt(n))do
if n mod i=0 then
begin
Prost:=false;
break;
end;
end;
function Hemming(n:longint):boolean;
var i:longint;
begin
Hemming:=true;
for i:=7 to n div 2 do
if Prost(i)and not(i in [2,3,5]) and(n mod i=0) then
begin
Hemming:=false;
break;
end;
end;
var n,a,k:integer;
begin
clrscr;
write('n=');readln(n);
a:=1;k:=1;
while k<=n do
begin
inc(a);
if ((a mod 2=0)or(a mod 3=0)or(a mod 5=0)) and Hemming(a) then
begin
inc(k);
write(a,' ');
end;
end;
writeln;
write('Hemming(',n,')=',a);
readln
end.