#include <bits/stdc++.h>
using namespace std;
void error(istream_iterator<string> _iterat) {}
template <typename T, typename... args>
void error(istream_iterator<string> _iterat, T a, args... arguments) {
  cerr << *_iterat << "=" << a << "\n";
  error(++_iterat, arguments...);
}
template <typename T, typename V>
void error(string pri, const pair<T, V> &z) {
  cerr << pri << "="
       << "{" << z.first << "," << z.second << "}"
       << "\n";
}
template <typename T, typename V>
void error(string pri, const map<T, V> &z) {
  cerr << pri << " is={";
  for (auto it = z.begin(); it != z.end(); ++it) {
    cerr << it->first << ":" << it->second;
    auto _it = z.end();
    _it--;
    if (it != _it) cerr << ",";
  }
  cerr << "}";
  cerr << "\n";
}
template <typename T>
void error(string pri, const vector<T> &z, long long st, long long ed) {
  cerr << pri << " in range[" << st << "," << ed << ")=[";
  for (long long i = st; i < ed; ++i) {
    cerr << z[i];
    if (i != ed - 1) cerr << " ";
  }
  cerr << "]";
  cerr << "\n";
}
template <typename T>
void error(string pri, const set<T> &z, long long st, long long ed) {
  cerr << pri << " in range[" << st << "," << ed << ")=[";
  long long tempcount = 0;
  for (auto it = z.begin(); it != z.end(); ++it) {
    if (tempcount >= st and tempcount < ed) {
      cerr << *it;
      if (tempcount != ed - 1) cerr << " ";
    }
    tempcount++;
  }
  cerr << "]";
  cerr << "\n";
}
template <typename T>
void error(string pri, const T z[], long long st, long long ed) {
  cerr << pri << " in range[" << st << "," << ed << ")=[";
  for (long long i = st; i < ed; ++i) {
    cerr << z[i];
    if (i != ed - 1) cerr << " ";
  }
  cerr << "]";
  cerr << "\n";
}
const long long s = 4;
const long long mod = pow(10, 9) + 7;
void mul(long long a1[s][s], long long a2[s][s]) {
  long long temp[s][s];
  for (long long i = 0; i < s; ++i) {
    for (long long j = 0; j < s; ++j) {
      temp[i][j] = 0;
      for (long long k = 0; k < s; ++k) {
        temp[i][j] = temp[i][j] % mod + (a1[i][k] % mod * a2[k][j] % mod) % mod;
        temp[i][j] = temp[i][j] % mod;
      }
    }
  }
  for (long long i = 0; i < s; ++i) {
    for (long long j = 0; j < s; ++j) {
      a1[i][j] = temp[i][j] % mod;
    }
  }
}
void power(long long arr[s][s], long long y) {
  long long ans[s][s];
  for (long long i = 0; i < s; ++i) {
    for (long long j = 0; j < s; ++j) {
      if (i == j)
        ans[i][j] = 1;
      else
        ans[i][j] = 0;
    }
  }
  while (y > 0) {
    if (y & 1) mul(ans, arr);
    mul(arr, arr);
    y = y >> 1;
  }
  for (long long i = 0; i < s; ++i) {
    for (long long j = 0; j < s; ++j) {
      arr[i][j] = ans[i][j] % mod;
    }
  }
}
void logic() {
  long long arr[s][s] = {
      {0, 1, 1, 1}, {1, 0, 1, 1}, {1, 1, 0, 1}, {1, 1, 1, 0}};
  long long n;
  cin >> n;
  if (n == 1)
    cout << 0;
  else {
    power(arr, n);
    cout << arr[0][0] % mod;
  }
  cout << "\n";
}
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(nullptr);
  long long t;
  { logic(); }
}
