#include<iostream>
using namespace std;

int main(){
  long long n,t[50];

  t[0] = 0;
  for(int i=1;i<=30;i++)t[i] = t[i-1]*3+1LL;

  while(cin >> n){
    if(n<=0){
      cout << "0\n";
      continue;
    }
    if(n&1)cout << t[n/2]*4+1 << endl;
    else cout << t[n/2-1]*3+t[n/2]+1 << endl;
  }
}