#include <bits/stdc++.h>
using namespace std;
long long int n, m, x;
void multiply(long long int **A, long long int **B) {
  long long int res[m][m];
  for (int i = 0; i < m; i++)
    for (int j = 0; j < m; j++) res[i][j] = 0;
  for (int i = 0; i < m; i++)
    for (int j = 0; j < m; j++)
      for (int k = 0; k < m; k++)
        res[i][j] =
            (res[i][j] + (A[i][k] % 1000000007 * B[k][j] % 1000000007)) %
            1000000007;
  for (int i = 0; i < m; i++)
    for (int j = 0; j < m; j++) A[i][j] = res[i][j];
}
int main() {
  int t = 1;
  while (t--) {
    cin >> n;
    m = 2;
    long long int **A;
    long long int **ans;
    A = new long long int *[m];
    ans = new long long int *[m];
    for (int i = 0; i < m; i++)
      A[i] = new long long int[m], ans[i] = new long long int[m];
    A[0][0] = 0, A[0][1] = 3, A[1][0] = 1, A[1][1] = 2;
    for (int i = 0; i < m; i++)
      for (int j = 0; j < m; j++)
        if (i == j)
          ans[i][j] = 1;
        else
          ans[i][j] = 0;
    while (n > 0) {
      if (n & 1) multiply(ans, A);
      n /= 2;
      multiply(A, A);
    }
    cout << ans[0][0] << endl;
  }
  return 0;
}
