#include <bits/stdc++.h>
const int MOD = (int)1e9 + 7;
int nextInt() {
  int tmp;
  scanf("%d", &tmp);
  return tmp;
}
void mul(int n, long long *A, long long *B, long long *C) {
  long long *_C = new long long[n * n];
  memset(_C, 0, n * n * sizeof(long long));
  for (int i = 0; i < n; ++i)
    for (int k = 0; k < n; ++k)
      for (int j = 0; j < n; ++j) _C[i * n + j] += A[i * n + k] * B[k * n + j];
  for (int i = 0; i < n; ++i)
    for (int j = 0; j < n; ++j) _C[i * n + j] %= MOD;
  memcpy(C, _C, n * n * sizeof(long long));
  delete _C;
}
int solve(int n) {
  long long X[4] = {1, 0, 0, 1};
  long long A[4] = {0, 3, 1, 2};
  while (n) {
    if (n & 1) mul(2, A, X, X);
    mul(2, A, A, A);
    n >>= 1;
  }
  return *X;
}
int main() {
  int n = nextInt();
  printf("%d\n", solve(n));
  return 0;
}
