#include <bits/stdc++.h>
using namespace std;
inline vector<vector<long long int> > mat_mul(
    vector<vector<long long int> > &A, vector<vector<long long int> > &B) {
  int n = A.size();
  vector<vector<long long int> > ans(n, vector<long long int>(n, 0));
  for (int i = 0; i < n; i++) {
    for (int j = 0; j < n; j++) {
      for (int k = 0; k < n; k++) {
        ans[i][j] = (ans[i][j] + (A[i][k] * B[k][j]) % 1000000007) % 1000000007;
      }
    }
  }
  return ans;
}
inline vector<vector<long long int> > mat_power(
    vector<vector<long long int> > &A, long long int b) {
  if (b == 1) {
    return A;
  }
  vector<vector<long long int> > ans = mat_power(A, b / 2);
  ans = mat_mul(ans, ans);
  if (b % 2) {
    ans = mat_mul(ans, A);
  }
  return ans;
}
int main() {
  ios_base::sync_with_stdio(false);
  long long int n;
  cin >> n;
  vector<vector<long long int> > v(2, vector<long long int>(2, 0));
  v[0][0] = 2;
  v[0][1] = 3;
  v[1][0] = 1;
  v[1][1] = 0;
  vector<vector<long long int> > ans = mat_power(v, n);
  cout << ans[1][1] << endl;
}
