#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>> res = {{0, 0}, {0, 0}};
  for (long long int i = 0; i < 2; i++)
    for (long long int j = 0; j < 2; j++)
      for (long long int k = 0; k < 2; k++)
        res[i][k] =
            ((res[i][k] % 1000000007) +
             (a[i][j] % 1000000007 * b[j][k] % 1000000007) % 1000000007) %
            1000000007;
  return res;
}
long long int binexp(vector<vector<long long int>> a, long long int n) {
  vector<vector<long long int>> ans = {{0, 1}, {0, 0}};
  while (n > 0) {
    if (n % 2) ans = multiply(ans, a);
    a = multiply(a, a);
    n /= 2;
  }
  return ans[0][1];
}
int32_t main() {
  long long int n;
  cin >> n;
  vector<vector<long long int>> x = {{2, 3}, {1, 0}};
  cout << binexp(x, n);
}
