program pil_6_33(input,output);
var
	c : char;
  num, cur, i, n, p : integer;
begin
	num := 0;
  read(c);
	while c<>' ' do begin
		num := 8*num + ord(c)-ord('0');
    read(c);
  end;
  p := 1;
  while num div p > 0 do begin
		p := p*5;
    n := n+1;
  end;
  p := p div 5;
  for i:=n downto 1 do begin
		cur := num div p;
    Write(cur);
    num := num - cur*p;
    p := p div 5;
  end;
  WriteLn;
end.