import sys input = sys.stdin.readline sys.setrecursionlimit(10**7) N=int(input()) mod=10**9+7 # 行列の計算(numpyを使えないとき,modを使用) def prod(A,B,k,l,m):# A:k*l,B:l*m C=[[None for i in range(m)] for j in range(k)] for i in range(k): for j in range(m): ANS=0 for pl in range(l): ANS=(ANS+A[i][pl]*B[pl][j])%mod C[i][j]=ANS return C def plus(A,B,k,l):# a,B:k*l C=[[None for i in range(l)] for j in range(k)] for i in range(k): for j in range(l): C[i][j]=(A[i][j]+B[i][j])%mod return C # 漸化式を行列累乗で求める(ダブリング) POWA=[[[0,1],[1,1]]] for i in range(60): POWA.append(prod(POWA[-1],POWA[-1],2,2,2)) # ベキを求めて def fib(N): X=[[1,1]] while N: X=prod(X,POWA[N.bit_length()-1],1,2,2) N-=1<<(N.bit_length()-1) return X[0][1] if N%2==0: print(fib((N-1)//2)) exit() A=[[0]*8 for i in range(8)] for i in range(7): A[i][i+1]=1 A[3][4]=0 A[4][4]=0 A[0][4]=1 A[1][0]=1 A[3][0]=1 A[5][4]=1 A[7][4]=1 POWA=[A] for i in range(60): POWA.append(prod(POWA[-1],POWA[-1],8,8,8)) # ベキを求めて X=[[1,0,0,0,0,0,0,0]] while N: X=prod(X,POWA[N.bit_length()-1],1,8,8) N-=1<<(N.bit_length()-1) print(X[0][4]%mod)