using System;
using System.Collections.Generic;
using System.Collections;
using System.Collections.Specialized;
using System.Linq;
using System.Text;
using System.Text.RegularExpressions;
using System.IO;
using System.Reflection;
using static System.Math;
using System.Numerics;
using System.Threading;
using System.Runtime.CompilerServices;
using System.Diagnostics;
static class Program {
const long inf = long.MaxValue>>1;
const int mod = (int)1e9+7;
static Sc sc = new Sc();
static void Main() {
Pt pt = new Pt(Solve);
pt.Sm();
}
static void Solve(Pt pt) {
var h = sc.L;
var ft = new Frontier(h+1,4,true);
ft.Ce1();
ft.Cc2();
pt.Wl(ft.Dp());
}
}
public class Frontier {
const long inf = long.MaxValue>>1;
const int mod = (int)1e9+7;
public int w, gn, gm;
public long h;
public List
li;
private bool isve;
public long[][] ba;
public Frontier(long h,int w,bool isve = false) {
this.h=h;
Dt.w=this.w=w;
this.isve=isve;
if(isve) gm=w;
else gm=(w+1)>>1;
Dt.gn=gn=(int)Ceiling(Log(gm,2));
}
public long Dp() {
var dp = Enumerable.Repeat(0L,li.Count).ToArray();
dp[0]=1;
var lar = li.Select((v,i) => new { v,i }).First(x => x.v.n==(1<<(w-1))).i;
for(int i = 0;i new { v,i }).First(x => x.v.n==(1<<(w-1))).i;
var mp = Mp2(dp,ba,h);
return mp[lar];
}
long[] Mp2(long[] r,long[][] x,long e) {
while(e>0) {
if((e&1)>0) { r=Mm(x,r); }
x=Mm(x,x);
e>>=1;
}
return r;
}
long[] Mm(long[][] a,long[] b) {
var q = new long[b.Length];
for(int j = 0;j>l)&1)==1) {
int pg = li[j].Geg(l)+li[k].c;
uf.Union(pg,o);
gb|=1<<(pg-li[k].c);
if(pg-li[k].c==0) { b0=true; }
}
}
if(li[j].g>0&&!b0) { goto lb; }
for(int i = 0;i0&&g1==0&&!uf.Same(i,li[k].c)) { goto lb; }
}
ba[j][k]=1;
lb:;
}
}
}
public void Cc2() {
ba=new long[li.Count][];
var ia = new int[gm];
var mm = 1<<(w-1);
for(int j = 0;j>l)&1)==1)
{
e++;
uf.Union(l+li[k].c+li[j].g,l+li[k].c+li[j].g+1);
}
if(l!=0&&((im>>(l-1))&1)==1)
{
e++;
uf.Union(l+li[k].c+li[j].g,l+li[k].c+li[j].g-1);
}
if(e!=0&&e!=2) { goto lb; }
}
var eds = 0;
for(int i = 0;i1||(eds!=0&&li[k].n!=0)) { goto lb; }
for(int i = 0;i();
for(int i = 0;i>a)&1)==0) Fu(a+1,p,g,c);
else if(!isve&&a!=0&&((i>>(a-1))&1)==1) { Fu(a+1,p+((p<();
for(int i = 0;i>k)&1)==0) { continue; }
if(Geb(bp,k)==j) { bp=Seb(bp,k,0); }
else if(Geb(bp,k)==0) { bp=Seb(bp,k,j); }
}
li.Add(new Dt(i,bp,g,c));
}
}
else if(((i>>a)&1)==0) Fu(a+1,p,g,c);
else if(!isve&&a!=0&&((i>>(a-1))&1)==1) { Fu(a+1,p+((p<();
for(int i = 0;i>a)&1)==0) Fu(a+1,p,c);
else if(!isve&&a!=0&&((i>>(a-1))&1)==1) { Fu(a+1,p+((p<>(k*gn))&((1<>1)&0x55555555;
bits=(bits&0x33333333)+((bits>>2)&0x33333333);
return ((bits+(bits>>4)&0xF0F0F0F)*0x1010101)>>24;
}
static int Pc(long bits) {
bits-=(bits>>1)&0x5555555555555555;
bits=(bits&0x3333333333333333)+(bits>>2&0x3333333333333333);
return (int)(((bits+(bits>>4))&0xf0f0f0f0f0f0f0f)*0x101010101010101>>56);
}
public class Dt {
public static int w, gn;
public int n, g, c;
public long b;
public Dt(int n,long b,int g,int c) {
this.n=n;
this.b=b;
this.g=g;
this.c=c;
}
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public int Geg(int k) { return (int)((b>>(k*gn))&((1<=0&&((n>>k)&1)==1; }
public override string ToString() {
var ca = new char[w];
for(int i = 0;is.Length ? new string('0',b-s.Length) : "")+s;
}
}
}
public class Uf {
private int[] arr, hi;
public int all;
public Uf(int n) {
arr=new int[n];
hi=new int[n];
all=n;
for(int i = 0;i f) { f(this); }
public void W(int s) { sb.Append(s); }
public void W(long s) { sb.Append(s); }
public void W(double s) { sb.Append(s); }
public void W(decimal s) { sb.Append(s); }
public void W(char s) { sb.Append(s); }
public void W(string s) { sb.Append(s); }
public void W(object s) { sb.Append(s); }
public void W(params object[] s) { sb.Append(string.Join(" ",s)); }
public void Wl(int s) { sb.Append(s).AppendLine(); }
public void Wl(long s) { sb.Append(s).AppendLine(); }
public void Wl(double s) { sb.Append(s).AppendLine(); }
public void Wl(decimal s) { sb.Append(s).AppendLine(); }
public void Wl(char s) { sb.Append(s).AppendLine(); }
public void Wl(string s) { sb.AppendLine(s); }
public void Wl(object s) { sb.Append(s).AppendLine(); }
public void Wl(IEnumerable s) { sb.AppendLine(string.Join(" ",s)); }
public void Wl(IEnumerable s) { sb.AppendLine(string.Join(" ",s)); }
public void Wl(IEnumerable s) { sb.AppendLine(string.Join(" ",s)); }
public void Wl(IEnumerable s) { sb.AppendLine(string.Join(" ",s)); }
public void Wl(params object[] s) { sb.AppendLine(string.Join(" ",s)); }
public void Wl() { sb.AppendLine(); }
public void Sm() { Console.Write(sb); }
public void Op(StreamWriter sw) {
sw.Write(sb);
sw.Close();
}
public static bool operator ==(Pt a,Pt b) { return a.sb.ToString()==b.sb.ToString(); }
public static bool operator !=(Pt a,Pt b) { return a.sb.ToString()!=b.sb.ToString(); }
public override bool Equals(object obj) { return false; }
public override int GetHashCode() { return 0; }
}
public class Sc {
[MethodImpl(MethodImplOptions.AggressiveInlining)]
protected virtual string Rl() { return Console.ReadLine(); }
[MethodImpl(MethodImplOptions.AggressiveInlining)]
protected virtual string[] Sp(string st) { return st.Split(); }
[MethodImpl(MethodImplOptions.AggressiveInlining)]
private T Ct(string s) { return (T)Convert.ChangeType(s,typeof(T)); }
public virtual int I { get { return int.Parse(Rl()); } }
public virtual long L { get { return long.Parse(Rl()); } }
public virtual double D { get { return double.Parse(Rl()); } }
public virtual string S { get { return Rl(); } }
public int[] Ia { get { return Array.ConvertAll(Sp(Rl()),int.Parse); } }
public long[] La { get { return Array.ConvertAll(Sp(Rl()),long.Parse); } }
public double[] Da { get { return Array.ConvertAll(Sp(Rl()),double.Parse); } }
public string[] Sa { get { return Sp(Rl()); } }
public object[] Oa { get { return Sp(Rl()); } }
public int[] Ia2 { get { return Array.ConvertAll(Sp("0 "+Rl()+" 0"),int.Parse); } }
public int[] Ia3(string a,string b) { return Array.ConvertAll(Sp(a+Rl()+b),int.Parse); }
public int[] Ia3(int a) { return Array.ConvertAll(Sp(Rl()+" "+a.ToString()),int.Parse); }
public long[] La2 { get { return Array.ConvertAll(Sp("0 "+Rl()+" 0"),long.Parse); } }
public long[] La3(string a,string b) { return Array.ConvertAll(Sp(a+Rl()+b),long.Parse); }
public long[] La3(int a) { return Array.ConvertAll(Sp(Rl()+" "+a.ToString()),long.Parse); }
public double[] Da2 { get { return Array.ConvertAll(Sp("0 "+Rl()+" 0"),double.Parse); } }
public double[] Da3(string a,string b) { return Array.ConvertAll(Sp(a+Rl()+b),double.Parse); }
public T[] Arr(int n,Func f) { var a = new T[n]; for(int i = 0;i(int n,Func f) { var a = new T[n]; for(int i = 0;i(int n,Func f) { var a = new T[n]; for(int i = 0;i(int n,Func f) { var a = new T[n]; for(int i = 0;i() { var s = Sp(Rl()); return (Ct(s[0]), Ct(s[1])); }
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public (T, T, T) Tp3() { var s = Sp(Rl()); return (Ct(s[0]), Ct(s[1]), Ct(s[2])); }
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public (T, T, T, T) Tp4() { var s = Sp(Rl()); return (Ct(s[0]), Ct(s[1]), Ct(s[2]), Ct(s[3])); }
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public (T, T, T, T, T) Tp5() { var s = Sp(Rl()); return (Ct(s[0]), Ct(s[1]), Ct(s[2]), Ct(s[3]), Ct(s[4])); }
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public (T, T, T, T, T, T) Tp6() { var s = Sp(Rl()); return (Ct(s[0]), Ct(s[1]), Ct(s[2]), Ct(s[3]), Ct(s[4]), Ct(s[5])); }
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public (T1, T2) Tp2() { var s = Sp(Rl()); return (Ct(s[0]), Ct(s[1])); }
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public (T1, T1, T2) Tp3() { var s = Sp(Rl()); return (Ct(s[0]), Ct(s[1]), Ct(s[2])); }
}
public class Scr:Sc {
private List li = new List();
private int l = 0;
private bool bo = false;
[MethodImpl(MethodImplOptions.AggressiveInlining)]
protected override string Rl() {
if(bo) { return li[l++%li.Count]; }
li.Add(Console.ReadLine());
return li[li.Count-1];
}
public void Again() { bo=true; }
}
public class Scs:Sc {
private StreamReader sr;
private string path;
public Scs(string path) { sr=new StreamReader(this.path=path); }
[MethodImpl(MethodImplOptions.AggressiveInlining)]
protected override string Rl() { return sr.ReadLine(); }
public void Close() { sr.Close(); }
public void Reset() { sr=new StreamReader(path); }
}
public class Sc2:Sc {
private string[] sps = new string[] { " "," ","\t" };
[MethodImpl(MethodImplOptions.AggressiveInlining)]
protected override string[] Sp(string st) { return st.Split(sps,StringSplitOptions.RemoveEmptyEntries); }
public override int I { get { return int.Parse(Sp(Rl())[0]); } }
public override long L { get { return long.Parse(Sp(Rl())[0]); } }
public override double D { get { return double.Parse(Sp(Rl())[0]); } }
public override string S { get { return Sp(Rl())[0]; } }
}
public class Scs2:Sc2 {
private StreamReader sr;
public Scs2(string t) { sr=new StreamReader(t); }
[MethodImpl(MethodImplOptions.AggressiveInlining)]
protected override string Rl() { return sr.ReadLine(); }
public void Close() { sr.Close(); }
}
public class Sct:Sc {
private List li = new List();
private int l = 0;
public void Add(int s) { li.Add(s.ToString()); }
public void Add(long s) { li.Add(s.ToString()); }
public void Add(double s) { li.Add(s.ToString()); }
public void Add(string s) { li.Add(s.ToString()); }
public void Add(object s) { li.Add(s.ToString()); }
public void Add(int[] s) { li.Add(string.Join(" ",s)); }
public void Add(long[] s) { li.Add(string.Join(" ",s)); }
public void Add(double[] s) { li.Add(string.Join(" ",s)); }
public void Add(string[] s) { li.Add(string.Join(" ",s)); }
public void Add(params object[] s) { li.Add(string.Join(" ",s)); }
protected override string Rl() { return li[l++]; }
public void Clear() { li.Clear(); l=0; }
public void Again() { l=0; }
public void Pf() { Console.WriteLine(string.Join("\n",li)); }
}