#include <bits/stdc++.h>
using namespace std;
const long long MOD = 1000000007;
class Matrix {
 public:
  long long m[4][4];
  Matrix(){};
  Matrix(long long k[4][4]) {
    for (int i = 0; i < 4; i++)
      for (int j = 0; j < 4; j++) m[i][j] = k[i][j];
  }
};
Matrix operator*(const Matrix &a, const Matrix &b) {
  Matrix t;
  for (int i = 0; i < 4; i++) {
    for (int j = 0; j < 4; j++) {
      t.m[i][j] = 0;
      for (int c = 0; c < 4; c++) {
        t.m[i][j] += (b.m[i][c]) * (a.m[c][j]);
        t.m[i][j] %= MOD;
      }
    }
  }
  return t;
}
Matrix pow(Matrix m, int p) {
  if (p == 1) return m;
  Matrix ret = pow(m, p / 2);
  if (p & 1) {
    return (ret * ret) * m;
  } else
    return (ret * ret);
}
int main() {
  int n;
  long long arr[4][4];
  scanf("%d", &n);
  for (int i = 0; i < 4; i++)
    for (int j = 0; j < 4; j++)
      if (i == j)
        arr[i][j] = 0;
      else
        arr[i][j] = 1;
  Matrix g(arr);
  Matrix ret = pow(g, n);
  cout << ret.m[3][3] % MOD << endl;
}
