#include <bits/stdc++.h>
using namespace std;
struct Matrix {
  int n, m;
  long long A[107][107];
  Matrix(int nsize, int msize) : n(nsize), m(msize) {}
  Matrix mulMod(Matrix &B, long long modulo) {
    Matrix C(n, B.m);
    for (int i = 1; i <= C.n; i++)
      for (int j = 1; j <= C.m; j++) {
        C.A[i][j] = 0;
        for (int k = 1; k <= m; k++)
          C.A[i][j] = (C.A[i][j] + A[i][k] * B.A[k][j]) % modulo;
      }
    return C;
  }
  Matrix power(long long p, long long modulo, Matrix &B) {
    Matrix res = B;
    Matrix M = B;
    p--;
    while (p) {
      if (p & 1) res = res.mulMod(M, modulo);
      M = M.mulMod(M, modulo);
      p >>= 1;
    }
    return res;
  }
  void print() {
    for (int i = 1; i <= n; i++) {
      for (int j = 1; j <= m; j++) cout << A[i][j] << ' ';
      cout << endl;
    }
  }
};
int main() {
  long long n;
  Matrix M(4, 4);
  for (int i = 1; i <= 4; i++)
    for (int j = 1; j <= 4; j++)
      if (i == j)
        M.A[i][j] = 0;
      else
        M.A[i][j] = 1;
  cin >> n;
  Matrix res = M.power(n, 1000000007, M);
  cout << res.A[1][1] << endl;
  return 0;
}
