const n =30;
var
s:string;
i,k,m:integer;
a:array[1..n] of integer;
b:array[1..n] of integer;
begin
for i:=1 to n do
readln(a[i]);
k:=1 ;
for i:=1 to n do
begin
str(a[i],s);
if pos('5',s) = 0 then
begin
b[k]:= a[i];
k:=k+1;
end; end;
for i:= 1 to n do
a[i]:=b[i];
for i:= 1 to n do
write(a[i],' ');
end.