Var a,i,b,r:integer; s,se:string; begin; readln(a); repeat b:=a mod 8; a:=a div 8; str(b,se); s+=se; until (a<=7); str(a,se); s+=se; for i:=1 to length(s) div 2 do begin; se:=s[i]; s[i]:=s[length(s)-i+1]; s[length(s)-i+1]:=se[1]; end; val(s,r,a); write(r); end.
s,se:string;
begin;
readln(a);
repeat
b:=a mod 8;
a:=a div 8;
str(b,se);
s+=se;
until (a<=7);
str(a,se);
s+=se;
for i:=1 to length(s) div 2 do
begin;
se:=s[i];
s[i]:=s[length(s)-i+1];
s[length(s)-i+1]:=se[1];
end;
val(s,r,a);
write(r);
end.