{
TASK:necklace
LANG:Pascal
}
program necklace;
var
  s,last,temp:string;
  left,right:int64;
  i,n,a,b,ans:longint;
function mul2(s:string):string;
var
  a,ret:string;
  code:integer;
  i,c,p,pren:longint;
begin
 ret:='';
 pren:=0;
 for i:=length(s) downto 1 do
 begin
  val(s[i],c,code);
  p:=c*2+pren;
  if i=1 then
  begin
   str(p,a);
   ret:=a+ret;
   break;
  end
   else
  begin
   if p<10 then
   begin
    pren:=0;
    str(p,a);
    ret:=a+ret;
   end
    else
   begin
    pren:=1;
    str(p mod 10,a);
    ret:=a+ret;
   end;
  end;
 end;
 mul2:=ret;
end;
function add1(s1:string):string;
var
  ret,a,s2:string;
  code:integer;
  i,c,d,p,pren:longint;
begin
 s2:='1';
 if length(s2)<length(s1) then
  for i:=1 to length(s1)-length(s2) do s2:='0'+s2;
 ret:='';
 pren:=0;
 for i:=length(s1) downto 1 do
 begin
  val(s1[i],c,code);
  val(s2[i],d,code);
  p:=c+d+pren;
  if i=1 then
  begin
   str(p,a);
   ret:=a+ret;
   break;
  end;
  if p<10 then
  begin
   pren:=0;
   str(p,a);
   ret:=a+ret;
  end
   else
  begin
   pren:=1;
   str(p mod 10,a);
   ret:=a+ret;
  end;
 end;
 add1:=ret;
end;
function dec1(s1:string):string;
var
  code:integer;
  s2,ret,a:string;
  i,c,d,p,pren:longint;
begin
{ if s1='0' then
 begin
  dec1:='0';
  exit;
 end;}
 s2:='1';
 if length(s2)<length(s1) then
  for i:=1 to length(s1)-length(s2) do s2:='0'+s2;
 ret:='';
 pren:=0;
 for i:=length(s1) downto 1 do
 begin
  val(s1[i],c,code);
  val(s2[i],d,code);
  p:=c-d-pren;
  if p>=0 then
  begin
   pren:=0;
   str(p,a);
   ret:=a+ret;
  end
   else
  begin
   pren:=1;
   p:=p+10;
   str(p,a);
   ret:=a+ret;
  end;
 end;
 while (length(ret)>1) and (ret[1]='0') do
  delete(ret,1,1);
 dec1:=ret;
end;
begin
   readln(n);
   if n=1 then
   begin
    writeln(0);
    halt;
   end;
   last:='0';
   for i:=2 to n do
   begin
{    left:=1 shl (i-1);
    right:=(1 shl i)-1;
    while left mod 3<>0 do left:=left+1;
    while right mod 3<>0 do right:=right-1;
    ans:=(right div 3)-(left div 3)+1;}

    temp:=mul2(last);
    if i mod 2=0 then  temp:=add1(temp) else
                       temp:=dec1(temp);
    {writeln(ans,' ',temp,' ',i);}
    last:=temp;
   end;
   writeln(temp);
   readln
end.