#include #include #include #include #include #include #include #include #include #include #include #include #include #include #include using namespace std; typedef long long ll; #define FOR(I,A,B) for(int I = (A); I < (B); ++I) struct Fibonacci { ll mod = 1000000007; ll add(ll x, ll y) { return (x += y) >= mod ? x - mod : x; } //template int add(int x, T... y) { return add(x, add(y...)); } ll mul(ll x, ll y) { return x * y % mod; } //template int mul(int x, T... y) { return mul(x, mul(y...)); } int sub(int x, int y) { return add(x, mod - y); } int modpow(int a, ll b) { int ret = 1; while(b > 0) { if(b & 1) ret = 1LL * ret * a % mod; a = 1LL * a * a % mod; b >>= 1; } return ret; } int modinv(int a) { return modpow(a, mod - 2); } typedef vector Vec; typedef vector Mat; // 行列*ベクトル Vec mulMatVec(Mat a, Vec b) { int n = b.size(); Vec ret(n, 0); FOR(i,0,n) FOR(j,0,n) ret[i] = add(ret[i], mul(a[i][j], b[j])); return ret; } // 行列*行列 Mat mulMatMat(Mat a, Mat b) { int n = a.size(); Mat ret(n, Vec(n, 0)); FOR(i,0,n) FOR(j,0,n) FOR(k,0,n) ret[i][j] = add(ret[i][j], mul(a[i][k], b[k][j])); return ret; } Mat fastpow(Mat x, ll n) { Mat ret(x.size(), Vec(x.size(), 0)); FOR(i,0,x.size()) ret[i][i] = 1; while(0 < n) { if ((n % 2) == 0) {x = mulMatMat(x, x); n >>= 1; } else { ret = mulMatMat(ret, x); --n; } } return ret; } void printVec(Vec a) { cout << "[\t"; FOR(i,0,a.size()) cout << a[i] << "\t"; cout << "]" << endl; } void printMac(Mat a) { FOR(i,0,a.size()) printVec(a[i]); } ll query(ll N, ll _mod) { mod = _mod; Mat m = Mat(2, Vec(2, 0)); m[0][0] = 1; m[0][1] = 1; m[1][0] = 1; Vec v = Vec(2, 0); v[0] = 1; m = fastpow(m, N); v = mulMatVec(m, v); return v[1]; } }; ll N; int main(){ cin >> N; Fibonacci fib; ll M = fib.query(N, 2000000016LL); ll ans = fib.query(M, 1000000007); cout << ans << endl; }