#include <bits/stdc++.h>
using namespace std;
const long long MOD = (long long)1e9 + 7;
void rec(long long n, long long a, long long b, long long &ra, long long &rb) {
  if (n == 0) {
    ra = 1;
    rb = 0;
    return;
  };
  if (n == 1) {
    ra = a;
    rb = b;
    return;
  };
  long long cra, crb;
  rec(n / 2, (a * a + b * b) % MOD, (2 * a * b) % MOD, cra, crb);
  if (n & 1LL) {
    ra = (cra * a + crb * b) % MOD;
    rb = (cra * b + crb * a) % MOD;
  } else {
    ra = cra;
    rb = crb;
  }
}
int main(int argc, char const *argv[]) {
  long long n, so, dmy;
  cin >> n;
  rec(n, 3, 1, so, dmy);
  cout << so << endl;
  return 0;
}
