#include <iostream>
#include <string>
#include <algorithm>
#include <cstring>
#include <map>
using namespace std;
map<int,string> dp;
string sum(string x,string y)//x大 y小
{
if(x.size()<y.size() || (x.size()==y.size() && x<y))
{
swap(x,y);
}
reverse(x.begin(),x.end());
reverse(y.begin(),y.end());
//int a[1000];
//int b[1000];
int c[1000];
memset(c,0,sizeof(c));
int jw=0;
for(int i=0,j=0;i<x.size();i++,j++)
{
int ta,tb;
if(j>=y.size())
{
tb=0;
}else
{
tb=y[j]-'0';
}
ta=x[i]-'0';
c[i]=(ta+tb+jw)%10;
jw=(ta+tb+jw)/10;
}
string jg="";
if(jw!=0)
{
string t="";
t=t+(char)(jw+'0');
jg=jg+t;
}
for(int i=x.size()-1;i>=0;i--)
{
string t="";
t=t+(char)(c[i]+'0');
jg=jg+t;
}
return jg;
}
string mul(string x,string y)//x大 y小
{
if(x.size()<y.size() || (x.size()==y.size() && x<y))
{
swap(x,y);
}
reverse(x.begin(),x.end());
reverse(y.begin(),y.end());
int c[2000];
memset(c,0,sizeof(c));
for(int i=0;i<x.size();i++)
{
int jw=0;
int j;
for(j=0;j<y.size();j++)
{
int ta=x[i]-'0';
int tb=y[j]-'0';
int t=c[j+i];
c[j+i]=(t+ta*tb+jw)%10;
jw=(t+ta*tb+jw)/10;
}
c[j+i]=jw;
}
int i=1999;
while(c[i]==0)
{
i--;
}
string jg="";
for(;i>=0;i--)
{
string ts="";
ts=ts+(char)(c[i]+'0');
jg=jg+ts;
}
return jg;
}
int main()
{
//dp[0]=1;
dp[0]="1";
//dp[1]=1;
//dp[2]=3;
dp[1]="1";
dp[2]="3";
for(int i=3;i<=250;i++)
{
//dp[i]=3*dp[i-2]+2*dp[i-3];
string t3="3";
string t2="2";
dp[i]=sum(mul(t3,dp[i-2]),mul(t2,dp[i-3]));
}
int n;
while(cin>>n)
{
cout<<dp[n]<<endl;
//string a,b;
//cin>>a>>b;
//cout<<sum(a,b)<<endl;
//cout<<mul(a,b)<<endl;
}
}