水
#include <bits/stdc++.h>
#define nmax 50
using namespace std;
int dp[nmax];
void init(){
dp[0] = 1;
dp[1] = 2;
dp[2] = 4;
for(int i = 3;i<nmax;++i){
dp[i] = dp[i-1] + dp[i-2] + dp[i-3];
}
}
int main()
{
int n;
init();
while(scanf("%d",&n) && n){
int ans = 1<<n;
printf("%d\n",ans - dp[n]);
}
return 0;
}