Program Zif_6_33(input,output);
var c:char;
    k,t,h:integer;
begin
     read(c);
     while c<>' ' do
     begin
          k:=k*8+ord(c)-ord('0');
          read(c)
     end;
     t:=1;
     while t*5<=k do t:=t*5;
     while t<>0 do
     begin
          h:=k div t;
          k:=k-h*t;
          c:=chr(h+ord('0'));
          write(c);
          t:=t div 5;
     end;
end.