struct A{
	ll d,x;
};
bool operator<(A const&a, A const&b){
	return a.d>b.d?true:a.d<b.d?false:a.x>b.x;
}
{
	vector<A> s[3];
	s[0].push_back({0,0});
	s[1].push_back({0,0});
	ll@n;
	rrep(h,n){
		ll@a[3];
		vector<A> t[3];
		rep(i,3){
			vector<A> u;
			rep(j,3){
				if(i!=j){
					for(auto b:s[j]){
						ll x=b.x+a[i];
						u.push_back({b.d+x,x=x==0?0:x-1});
					}
				}
			}
			sort(u.begin(),u.end());
			ll w=-1;
			for(auto b:u){
				if(b.x>w){
					w=b.x;
					t[i].push_back(b);
				}
			}
		}
		rep(i,3){
			s[i]=t[i];
		}
	}
	ll z=0;
	rep(i,3){
		for(auto b:s[i]){
			z=max(z,b.d);
		}
	}
	wt(z);
}