program hanoi;
const
jin=10000;
type
gjd=array[1..20]of longint;
var
f1,f2:text;
n:integer;
a:gjd;
procedure main(n:integer);
var
i,j,k:integer;
begin
fillchar(a,sizeof(a),0);
a[20]:=2;
for i:=2 to n+1 do begin
for j:=20 downto 1 do a[j]:=a[j]*2;
for j:=20 downto 2 do begin
a[j-1]:=(a[j]div jin)+a[j-1];
a[j]:=a[j]mod jin;
end;
end;
i:=20;
while (a[i]=0) and(i>1)do dec(i);
if i<>20 then begin
a[20]:=8;
for j:=i to 19 do a[i]:=999;
end
else a[20]:=a[20]-2;
end;
procedure ini;
begin
assign(f1,'hanoi.in');reset(f1);
assign(f2,'hanoi.out');rewrite(f2);
read(f1,n);
close(f1);
end;
procedure pr;
var
i,j,k,e,c:integer;
begin
i:=1;
while(i<20)and(a[i]=0)do inc(i);
write(f2,a[i]);
for j:=i+1 to 20 do begin
if a[j]div 1000<>0 then write(f2,a[j])
else begin
e:=10;c:=1;
while (a[j]div e<>0)and(c<=4)do begin
inc(c);
e:=e*10;
end;
for e:=1 to c-1 do write(f2,0);
write(f2,a[j]);
end;
end;
writeln(f2);
end;
begin
ini;
if n=0 then writeln(f2,0)
else begin
main(n);
pr;
end;
close(f2);
end.