#include <bits/stdc++.h>
using namespace std;
const long long MAXN = 1000005;
const long long SQRTN = 1003;
const long long LOGN = 22;
const double PI = acos(-1);
const long long INF = 1e18;
const long long MOD = 1e9 + 7;
const long long FMOD = 998244353;
const double eps = 1e-9;
struct Matrix {
  vector<vector<long long> > mat;
  long long n_rows, n_cols;
  Matrix() {}
  Matrix(vector<vector<long long> > values)
      : mat(values), n_rows(values.size()), n_cols(values[0].size()) {}
  static Matrix identity_matrix(long long n) {
    vector<vector<long long> > values(n, vector<long long>(n, 0));
    for (long long i = 0; i < n; i++) values[i][i] = 1;
    return values;
  }
  Matrix operator*(const Matrix &other) const {
    long long n = n_rows, m = other.n_cols;
    vector<vector<long long> > result(n_rows, vector<long long>(n_cols, 0));
    for (long long i = 0; i < n; i++)
      for (long long j = 0; j < m; j++) {
        long long tmp = 0;
        for (long long k = 0; k < n_cols; k++) {
          tmp += mat[i][k] * 1ll * other.mat[k][j];
          while (tmp >= MOD) tmp -= MOD;
        }
        result[i][j] = tmp % MOD;
      }
    return move(Matrix(move(result)));
  }
  inline bool is_square() const { return n_rows == n_cols; }
};
Matrix pw(Matrix a, long long p) {
  Matrix result = Matrix::identity_matrix(a.n_cols);
  while (p > 0) {
    if (p & 1) result = a * result;
    a = a * a;
    p >>= 1;
  }
  return result;
}
const int32_t N = 1e7 + 1;
int32_t dp[4][N + 1];
void solvethetestcase() {
  int32_t n;
  cin >> n;
  dp[0][0] = 0;
  dp[1][0] = 0;
  dp[2][0] = 0;
  dp[3][0] = 1;
  for (long long i = 1; i < n + 1; i++) {
    dp[0][i] +=
        (dp[1][i - 1] % MOD + dp[2][i - 1] % MOD + dp[3][i - 1] % MOD) % MOD;
    dp[1][i] +=
        (dp[0][i - 1] % MOD + dp[2][i - 1] % MOD + dp[3][i - 1] % MOD) % MOD;
    dp[2][i] +=
        (dp[0][i - 1] % MOD + dp[1][i - 1] % MOD + dp[3][i - 1] % MOD) % MOD;
    dp[3][i] +=
        (dp[0][i - 1] % MOD + dp[1][i - 1] % MOD + dp[2][i - 1] % MOD) % MOD;
  }
  cout << dp[3][n] << "\n";
}
signed main() {
  cout << fixed << setprecision(12);
  ;
  ios::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  long long t = 1;
  for (long long testcase = 1; testcase < t + 1; testcase++) {
    solvethetestcase();
  }
}
