#include <bits/stdc++.h>
using namespace std;
int base = 1e9 + 7;
long long n, D = 1, ABC;
int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  cin >> n;
  for (int i = 1; i <= n; i++) {
    long long nD = (ABC * 3) % base;
    long long nABC = (ABC * 2 + D) % base;
    D = nD;
    ABC = nABC;
  }
  cout << D;
  return 0;
}
