#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define mod 1000000007
int main()
{
ll n, fd, tmp_fd, fa, tmp_fa, fb, tmp_fb, fc, tmp_fc;
fd = 0, fa = fb = fc = 1;
cin >> n;
for (ll i = 2; i <= n; i++)
{
tmp_fd = fd;
fd = (fa + fb + fc) % mod;
tmp_fa = fa;
fa = (tmp_fd + fb + fc) % mod;
tmp_fb = fb;
fb = (tmp_fa + tmp_fd + fc) % mod;
tmp_fc = fc;
fc = (tmp_fa + tmp_fb + tmp_fd) % mod;
}
cout << fd;
}
I2luY2x1ZGUgPGJpdHMvc3RkYysrLmg+CnVzaW5nIG5hbWVzcGFjZSBzdGQ7CiNkZWZpbmUgbGwgbG9uZyBsb25nCiNkZWZpbmUgbW9kIDEwMDAwMDAwMDcKCmludCBtYWluKCkKewogICAgICAgIGxsIG4sIGZkLCB0bXBfZmQsIGZhLCB0bXBfZmEsIGZiLCB0bXBfZmIsIGZjLCB0bXBfZmM7CiAgICAgICAgZmQgPSAwLCBmYSA9IGZiID0gZmMgPSAxOwogICAgICAgIGNpbiA+PiBuOwogIAogICAgICAgIGZvciAobGwgaSA9IDI7IGkgPD0gbjsgaSsrKQogICAgICAgIHsKCiAgICAgICAgICAgICAgICB0bXBfZmQgPSBmZDsKICAgICAgICAgICAgICAgIGZkID0gKGZhICsgZmIgKyBmYykgJSBtb2Q7CiAgICAgICAgICAgICAgICB0bXBfZmEgPSBmYTsKICAgICAgICAgICAgICAgIGZhID0gKHRtcF9mZCArIGZiICsgZmMpICUgbW9kOwogICAgICAgICAgICAgICAgdG1wX2ZiID0gZmI7CiAgICAgICAgICAgICAgICBmYiA9ICh0bXBfZmEgKyB0bXBfZmQgKyBmYykgJSBtb2Q7CiAgICAgICAgICAgICAgICB0bXBfZmMgPSBmYzsKICAgICAgICAgICAgICAgIGZjID0gKHRtcF9mYSArIHRtcF9mYiArIHRtcF9mZCkgJSBtb2Q7CiAgICAgICAgfQogICAgICAgIGNvdXQgPDwgZmQ7Cn0=