#include <bits/stdc++.h>
using namespace std;
const int mod = 1e9 + 7;
int n;
vector<vector<long long>> x, y, identity;
vector<vector<long long>> mul(vector<vector<long long>> x,
                              vector<vector<long long>> y) {
  vector<vector<long long>> res;
  res.assign(x.size(), vector<long long>(x[0].size()));
  for (int i = 0; i < x.size(); ++i) {
    for (int j = 0; j < x[i].size(); ++j) {
      for (int k = 0; k < y.size(); ++k) {
        res[i][k] += x[i][j] * y[j][k];
        res[i][k] %= mod;
      }
    }
  }
  return res;
}
vector<vector<long long>> pw(vector<vector<long long>> x, int d) {
  if (!d) return identity;
  if (d & 1) return mul(x, pw(x, d - 1));
  return pw(mul(x, x), d / 2);
}
int main() {
  ios::sync_with_stdio(0);
  cin >> n;
  identity = {{1, 0, 0, 0}, {0, 1, 0, 0}, {0, 0, 1, 0}, {0, 0, 0, 1}};
  x = {{1, 0, 0, 0}, {0, 0, 0, 0}, {0, 0, 0, 0}, {0, 0, 0, 0}};
  y = {{0, 1, 1, 1}, {1, 0, 1, 1}, {1, 1, 0, 1}, {1, 1, 1, 0}};
  vector<vector<long long>> res = mul(x, pw(y, n));
  cout << res[0][0] << '\n';
  return 0;
}
