#include <bits/stdc++.h>
using namespace std;
int main() {
  ios::sync_with_stdio(0);
  cin.tie(0);
  long long n, arr[4][4],
      base[4][4] = {{0, 1, 1, 1}, {1, 0, 1, 1}, {1, 1, 0, 1}, {1, 1, 1, 0}},
      temp[4][4], mod = 1e9 + 7;
  for (long long i = 0; i < 4; i++) {
    for (long long j = 0; j < 4; j++) arr[i][j] = (1 - base[i][j]);
  }
  cin >> n;
  n--;
  while (n) {
    if (n & 1) {
      for (long long i = 0; i < 4; i++) {
        for (long long j = 0; j < 4; j++) {
          temp[i][j] = 0;
          for (long long k = 0; k < 4; k++)
            temp[i][j] += arr[i][k] * base[k][j];
        }
      }
      for (long long i = 0; i < 4; i++) {
        for (long long j = 0; j < 4; j++) arr[i][j] = temp[i][j] % mod;
      }
    }
    for (long long i = 0; i < 4; i++) {
      for (long long j = 0; j < 4; j++) {
        temp[i][j] = 0;
        for (long long k = 0; k < 4; k++) temp[i][j] += base[i][k] * base[k][j];
      }
    }
    for (long long i = 0; i < 4; i++) {
      for (long long j = 0; j < 4; j++) base[i][j] = temp[i][j] % mod;
    }
    n >>= 1;
  }
  cout << (arr[3][0] + arr[2][0] + arr[1][0]) % mod;
}
