n = int(input()) P = 10 ** 9 + 7 def seki(x,y): m = len(x) l = [[0] * m for _ in range(m)] for i in range(m): for j in range(m): for k in range(m): l[i][j] = (l[i][j] + x[i][k] * y[k][j]) % P return l import sys if n == 1: print(1) exit() elif n == 2: print(1) exit() elif n == 3: print(3) exit() elif n == 4: print(2) exit() if n % 2 == 0: m = 2 R = [[1,1,],[1,0]] else: m = 4 R = [[1,1,1,1,],[1,0,0,0,],[0,1,0,0,],[0,0,1,0]] e = [[0] * m for _ in range(m)] for i in range(m): e[i][i] = 1 if n % 2 == 0: u = n // 2 - 2 while u: if u & 1: e = seki(e,R) u >>= 1 R = seki(R,R) ans = e[0][0] * 2 + e[0][1] * 1 print(ans % P) else: u = n - 4 while u: if u & 1: e = seki(e,R) u >>= 1 R = seki(R,R) ans = e[0][0] * 2 + e[0][1] * 3 + e[0][2] * 1 * e[0][3] print(ans)