#include <bits/stdc++.h>
const long long P = 1000000007;
long long N, oldA, oldB, oldC, oldD = 1, newA, newB, newC, newD;
int main() {
  std::cin >> N;
  for (int i = 1; i <= N; ++i) {
    newA = (oldB + oldC + oldD) % P;
    newB = (oldA + oldC + oldD) % P;
    newC = (oldA + oldB + oldD) % P;
    newD = (oldA + oldB + oldC) % P;
    oldA = newA;
    oldB = newB;
    oldC = newC;
    oldD = newD;
  }
  std::cout << newD;
}
