import numpy as np MOD=10**9+7 a=np.array([[0,1],[3,2]],dtype=np.int64) def pow_mat(a,n): ret=np.eye(2,dtype=np.int64) while n>0: if n%2==1: ret=np.dot(ret,a)%MOD a=np.dot(a,a)%MOD n//=2 return ret n=int(input()) a=pow_mat(a,n) print(a[0][0])