#include #include #include #define repeat(i,n) for (int i = 0; (i) < int(n); ++(i)) typedef long long ll; using namespace std; template auto vectors(X x, T a) { return vector(x, a); } template auto vectors(X x, Y y, Z z, Zs... zs) { auto cont = vectors(y, z, zs...); return vector(x, cont); } vector > mul(vector > const & a, vector > const & b, ll m) { int n = a.size(); vector > c = vectors(n, n, ll()); repeat (y,n) repeat (z,n) repeat (x,n) c[y][x] = (c[y][x] + a[y][z] * b[z][x] % m) % m; return c; } vector mul(vector > const & a, vector const & b, ll m) { int n = a.size(); vector c(n); repeat (y,n) repeat (z,n) c[y] = (c[y] + a[y][z] * b[z] % m) % m; return c; } vector > unit_matrix(int n) { vector > e = vectors(n, n, ll()); repeat (i,n) e[i][i] = 1; return e; } template T powt(T x, ll y, T unit, F f) { T z = unit; for (ll i = 1; i <= y; i <<= 1) { if (y & i) z = f(z, x); x = f(x, x); } return z; } ll fib(ll n, ll m) { vector > f { { 1, 1 }, { 1, 0 } }; vector x { 0, 1 }; return mul(powt(f, n, unit_matrix(2), [&](auto a, auto b) { return mul(a, b, m); }), x, m)[0]; } const ll mod = 1000000007; const ll cycle = 2000000016; void unittest() { for (int i = 0, a = 0, b = 1; i < 1000; swap(a, b), a = (a + b) % mod, ++ i) assert (fib(i, mod) == a); for (ll i = cycle - 100; i < cycle + 100; ++ i) assert (fib(i, mod) == fib(i % cycle, mod)); } int main() { // unittest(); ll n; cin >> n; assert (0 <= n and n <= 1000000000000000000ll); cout << fib(fib(n, cycle), mod) << endl; return 0; }