#include <bits/stdc++.h>
using namespace std;
struct node {
  long long a[4][4];
};
node multi(long long a[4][4], long long b[4][4]) {
  node k;
  for (long long c = 0; c < 4; c++) {
    for (long long i = 0; i < 4; i++) {
      long long sum = 0;
      for (long long j = 0; j < 4; j++) {
        sum += (a[i][j] * b[j][c]) % 1000000007;
      }
      k.a[i][c] = sum % 1000000007;
    }
  }
  return k;
}
node power(long long a[4][4], long long p) {
  if (p == 1) {
    node h;
    for (long long i = 0; i < 4; i++)
      for (long long j = 0; j < 4; j++) h.a[i][j] = a[i][j];
    return h;
  }
  if (p % 2 == 1) {
    p--;
    node ret = power(a, p / 2);
    return multi(a, multi(ret.a, ret.a).a);
  } else {
    node ret = power(a, p / 2);
    return multi(ret.a, ret.a);
  }
}
int main() {
  long long a[4][4] = {{0, 1, 1, 1}, {1, 0, 1, 1}, {1, 1, 0, 1}, {1, 1, 1, 0}};
  long long n;
  scanf("%I64d", &n);
  node k = power(a, n);
  printf("%I64d\n", k.a[3][3] % 1000000007);
}
