#include <bits/stdc++.h>
using namespace std;
const int mod = (int)1e9 + 7;
const int inf = (int)(1e9);
const double eps = 1e-9;
const int N = 100005;
long long a[4][4];
long long res[4][4];
long long dres[4][4];
int n;
void binpow(int n) {
  for (int(i) = 0; (i) < (4); ++(i))
    for (int(j) = 0; (j) < (4); ++(j)) res[i][j] = (i == j);
  while (n) {
    if (n & 1) {
      for (int(i) = 0; (i) < (4); ++(i))
        for (int(j) = 0; (j) < (4); ++(j)) {
          dres[i][j] = res[i][j];
          res[i][j] = 0;
        }
      for (int(i) = 0; (i) < (4); ++(i))
        for (int(j) = 0; (j) < (4); ++(j))
          for (int(k) = 0; (k) < (4); ++(k)) {
            res[i][j] += dres[i][k] * a[k][j];
            res[i][j] %= mod;
          }
    }
    n /= 2;
    for (int(i) = 0; (i) < (4); ++(i))
      for (int(j) = 0; (j) < (4); ++(j)) {
        dres[i][j] = a[i][j];
        a[i][j] = 0;
      }
    for (int(i) = 0; (i) < (4); ++(i))
      for (int(j) = 0; (j) < (4); ++(j))
        for (int(k) = 0; (k) < (4); ++(k)) {
          a[i][j] += dres[i][k] * dres[k][j];
          a[i][j] %= mod;
        }
  }
}
int main() {
  cin >> n;
  for (int(i) = 0; (i) < (4); ++(i))
    for (int(j) = 0; (j) < (4); ++(j)) a[i][j] = (i != j);
  binpow(n);
  cout << res[0][0] % mod << endl;
  return 0;
}
