#include <bits/stdc++.h>
using namespace std;
const long long MOD = (1e9) + 7;
int n;
long long f[30][4][4], tmp[4][4], res[4][4];
void mult(long long a[4][4], long long b[4][4], long long st[4][4]) {
  for (int i = 0; i < 4; i++)
    for (int j = 0; j < 4; j++)
      for (int k = 0; k < 4; k++)
        st[i][j] = (st[i][j] + a[i][k] * b[k][j]) % MOD;
}
int main() {
  cin >> n;
  for (int i = 0; i < 4; i++)
    for (int j = 0; j < 4; j++) {
      if (i != j)
        f[0][i][j] = 1;
      else
        res[i][j] = 1;
    }
  for (int p = 1; (1 << p) <= n; p++) mult(f[p - 1], f[p - 1], f[p]);
  for (int p = 0; (1 << p) <= n; p++)
    if ((1 << p) & n) {
      for (int i = 0; i < 4; i++)
        for (int j = 0; j < 4; j++) tmp[i][j] = res[i][j], res[i][j] = 0;
      mult(tmp, f[p], res);
    }
  cout << res[3][3];
}
