#include <bits/stdc++.h>
using namespace std;
vector<vector<long long> > MATT(vector<vector<long long> > b,
                                vector<vector<long long> > a) {
  vector<vector<long long> > sol;
  for (int i = 0; i < a.size(); i++) {
    vector<long long> t;
    for (int j = 0; j < b[0].size(); j++) {
      t.push_back(0);
    }
    sol.push_back(t);
  }
  for (int i = 0; i < b[0].size(); i++) {
    for (int j = 0; j < a.size(); j++) {
      long long x = 0;
      for (int k = 0; k < b.size(); k++) {
        x += (a[j][k] * b[k][i]) % 1000000007;
      }
      sol[j][i] = x % 1000000007;
    }
  }
  return sol;
}
vector<vector<long long> > power(vector<vector<long long> > a, int b) {
  if (b == 1) return a;
  vector<vector<long long> > x;
  x = power(a, b / 2);
  if (b % 2 == 0)
    return MATT(x, x);
  else
    return MATT(a, MATT(x, x));
}
int main() {
  vector<vector<long long> > matrix;
  vector<vector<long long> > sol;
  for (int i = 0; i < 4; i++) {
    vector<long long> temp;
    for (int j = 0; j < 4; j++) {
      temp.push_back(1);
    }
    matrix.push_back(temp);
    temp.clear();
    if (i == 0)
      temp.push_back(1);
    else
      temp.push_back(0);
    sol.push_back(temp);
    matrix[i][i] = 0;
  }
  int n;
  cin >> n;
  matrix = power(matrix, n);
  sol = MATT(sol, matrix);
  cout << sol[0][0] << endl;
}
