#include <bits/stdc++.h>
using namespace std;
const int M = 1e9 + 7;
vector<long long> dp(4, 0), a(4, 0);
int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  int n;
  cin >> n;
  dp[0] = 1;
  for (int i = 1; i <= n; i++) {
    a[0] = a[1] = a[2] = a[3] = 0;
    a[0] = 1ll * (dp[1] + dp[2] + dp[3]) % M;
    a[1] = 1ll * (dp[0] + dp[2] + dp[3]) % M;
    a[2] = 1ll * (dp[0] + dp[1] + dp[3]) % M;
    a[3] = 1ll * (dp[0] + dp[1] + dp[2]) % M;
    for (int j = 0; j < 4; j++) {
      dp[j] = a[j];
    }
  }
  cout << dp[0];
  return 0;
}
