ll@n;
if(n>=16){
	wt(65535);
	exit(0);
}
set<ll>g,h;
h.insert(0);
rep(n){
	ll@a;
	for(ll k:h){
		rep(16){
			g.insert(a|k);
			a=a*2%65535;
		}
	}
	swap(g,h);g.clear();
}
rrep(i,65536){
	if(h.find(i)!=h.end()){
		wt(i);
		exit(0);
	}
}