#include <bits/stdc++.h>
using namespace std;
vector<vector<long long int>> multiply(vector<vector<long long int>> a,
                                       vector<vector<long long int>> b) {
  vector<vector<long long int>> v(4, vector<long long int>(4, 0));
  for (long long int i = 0; i < 4; i++) {
    for (long long int j = 0; j < 4; j++) {
      for (long long int k = 0; k < 4; k++)
        v[i][j] = (v[i][j] + a[i][k] * b[k][j]) % 1000000007;
    }
  }
  return v;
}
vector<vector<long long int>> power(vector<vector<long long int>> v,
                                    long long int k) {
  if (k == 1) return v;
  vector<vector<long long int>> res = power(v, k / 2);
  if (1 & k)
    res = multiply(multiply(res, res), v);
  else
    res = multiply(res, res);
  return res;
}
long long int solve(vector<vector<long long int>> a, long long int k) {
  vector<vector<long long int>> b(4, vector<long long int>(4));
  b = power(a, k);
  return b[0][0];
}
signed main() {
  ios::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  long long int n;
  cin >> n;
  vector<vector<long long int>> a(4, vector<long long int>(4));
  for (long long int i = 0; i < 4; i++) {
    for (long long int j = 0; j < 4; j++) {
      if (i == j)
        a[i][j] = 0;
      else
        a[i][j] = 1;
    }
  }
  cout << solve(a, n);
}
