#include <bits/stdc++.h>
using namespace std;
long long power(long long x, long long n);
long long mod = 1e9 + 7;
void test_case() {
  long long n;
  cin >> n;
  long long d = 1;
  long long abc = 0;
  for (long long i = 1; i <= n; i++) {
    long long nd = 3 * abc % mod;
    long long nabc = (2 * abc + d) % mod;
    d = nd;
    abc = nabc;
  }
  cout << d;
}
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  cout.tie(NULL);
  test_case();
}
long long power(long long x, long long n) {
  long long ans = 1;
  while (n > 0) {
    if (n & 1) ans *= x;
    n >>= 1;
    x *= x;
  }
  return ans;
}
