program find;
var
a,b,c:array[0..2000001]of longint;
r:array[0..9]of lOngint=(0,7,4,1,8,5,2,9,6,3);
e:array[0..9]of lOngint=(0,2,1,0,2,1,0,2,1,0);
n,i,m:longint;
s:ansistring;
procedure get;
var i,s,v,x,k:longint;
begin
s:=0; v:=0;
for i:=n downto 1 do
begin
if b[i]<0 then k:=(abs(b[i]) div 10+ord(abs(b[i]) mod 10<>0)) else k:=0;
if b[i]<0 then b[i]:=k*10-abs(b[i]);
c[i]:=r[b[i]]; b[i-1]:=b[i-1]-e[b[i]]-k;
end;
for i:=1 to n do
write(c[i]);
end;
procedure work;
var i,s,v,x,k:longint;
begin
s:=0; v:=0;
for i:=n downto 1 do
begin
if i=1 then v:=v-b[n]+(r[a[n]]*2)mod 10;
if v<=a[i] then k:=0
else k:=(v-a[i]) div 10+ord((v-a[i]) mod 10>0);
x:=a[i]+k*10-v;
b[i]:=x;
a[i-1]:=a[i-1]-k;
v:=v+x;
end;
get;
end;
begin
readln(s);
n:=length(s);
for i:=1 to n do
a[i]:=ord(s[i])-48;
work;
end.