program kitu;
uses crt;
var i,j,k:integer;
s1,s2:string;
begin
clrscr;
write('nhap xau:')readln(s1);
s2:=''
for i:=1 to length(s1) do
if (s1[i]>='1')and(s1[i]<='9')then s2:=s2+21[i];
for i = 1 to 4
k:=i;
for j:=i to length(s)+i-4 do
if s2[k]<s2[j] then k:=j;
if k>i then delete(s,i,k-i);
end;
writeln(copy(s,1,4));
readln;
end.