import java.util.Arrays; import java.util.Scanner; public class Main { public static void main(String[] args) { new Main().run(); } final long MOD = 1000000007; void run() { Scanner sc = new Scanner(System.in); long N = sc.nextLong(); long[][] mat = { { 1, 1, 0, 0 }, { 0, 1, 1, 2 }, { 0, 1, 0, 0 }, { 0, 1, 0, 1 } }; long[][] v = { { 0 }, { 1 }, { 0 }, { 0 } }; mat = pow(mat, N); mat = mul(mat, v); System.out.println(mat[0][0]); } long[][] pow(long[][] a, long n) { long[][] ret = new long[a.length][a.length]; for (int i = 0; i < a.length; ++i) ret[i][i] = 1; for (; n > 0; n >>= 1, a = mul(a, a)) { if (n % 2 == 1) ret = mul(a, ret); } return ret; } long[][] mul(long[][] a, long[][] b) { long[][] ret = new long[a.length][b[0].length]; for (int i = 0; i < a.length; ++i) { for (int j = 0; j < b[i].length; ++j) { for (int k = 0; k < a[i].length; ++k) { ret[i][j] = (ret[i][j] + a[i][k] * b[k][j]) % MOD; } } } return ret; } void tr(Object... objects) { System.out.println(Arrays.deepToString(objects)); } }