Var
//a:array[1..4] of integer;
b,i,max,mz,a1,a2,a3,a4:integer;
Begin
Readln(b);
a1:= b div 1000;
a2:= b div 100 mod 10;
a3:= b div 10 mod 10;
a4:= b mod 10;
for i:=1 to 4 do begin
max:=-1;
mz:=0;
if a1>max then begin max:=1; mz:=a1; end;
if a2>mz then begin max:=2; mz:=a2; end;
if a3>mz then begin max:=3; mz:=a3; end;
if a4>mz then begin max:=4; mz:=a4; end;
if max=1 then Begin Write(mz); a1:=0 End;
if max=2 then Begin Write(mz); a2:=0 End;
if max=3 then Begin Write(mz); a3:=0 End;
if max=4