#include <bits/stdc++.h>
using namespace std;
const char nl = '\n';
const long long inf = 1e9 + 10;
const long long inf2 = 1e18 + 99LL;
const long double inf3 = 1e16;
const long long mod = 1e9 + 7, mod2 = 998244353;
const long double eps = 1e-9;
const bool local = false;
const int logn = 18, maxn = 3001, maxm = 10001, maxn2 = 3;
const long long tn = 4;
struct Matrix {
  long long a[tn][tn];
  Matrix(long long x = 0) {
    for (int i = 0; i < tn; i++) {
      for (int j = 0; j < tn; j++) a[i][j] = 0;
      a[i][i] = x;
    }
  }
  Matrix operator*(const Matrix &b) {
    Matrix res;
    for (int i = 0; i < tn; i++) {
      for (int j = 0; j < tn; j++) {
        for (int k = 0; k < tn; k++) {
          res.a[i][k] += a[i][j] * b.a[j][k];
          res.a[i][k] %= mod;
        }
      }
    }
    return res;
  }
};
Matrix bp(Matrix a, long long n) {
  Matrix res(1);
  while (n) {
    if (n & 1) res = res * a;
    a = a * a;
    n >>= 1;
  }
  return res;
}
int main() {
  ios::sync_with_stdio(false);
  cin.tie(NULL);
  cout.tie(NULL);
  ;
  int k;
  cin >> k;
  Matrix a;
  for (int i = 0; i < 4; i++) {
    for (int j = 0; j < 4; j++) {
      if (i == j) continue;
      a.a[i][j] = 1;
    }
  }
  auto res = bp(a, k);
  cout << res.a[3][3] << nl;
}
