#include <bits/stdc++.h>
using namespace std;
const int M = 1e7 + 5;
long long mod = 1e9 + 7;
template <typename TT>
ostream &operator<<(ostream &oov, const vector<TT> &a) {
  for (int i = 0; i < a.size(); i++) {
    oov << a[i];
    if (i != a.size() - 1) oov << " ";
  }
  oov << "\n";
  return oov;
}
struct fun {
  int node;
  int cost;
  fun(int n, int c) {
    node = n;
    cost = c;
  }
};
vector<vector<int> > adj(4);
int dp[4][3];
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  for (int i = 0; i < 4; i++) {
    for (int j = 0; j < 4; j++) {
      if (j != i) adj[i].push_back(j);
    }
  }
  long long mcos, n0 = 1, n1 = 0, d0, d1;
  cin >> mcos;
  for (int i = mcos - 1; i >= 0; i--) {
    d0 = (3 * n1) % mod;
    d1 = (n0 + 2 * n1 % mod) % mod;
    swap(n0, d0);
    swap(n1, d1);
  }
  cout << (n0 % mod);
  return 0;
}
