#include #define rep(i,a,b) for(int i=int(a);i > MAT; int INF = (1LL << 30) - 1; ll MOD = 1e9+7; MAT mulmat(MAT a,MAT b,ll m){ //ll mat[2][2] = {}; auto mat = MAT (2, vector(2)); mat[0][0] = ((a[0][0] * b[0][0]) % m + (a[0][1] * b[1][0]) % m) % m; mat[0][1] = ((a[0][0] * b[0][1]) % m + (a[0][1] * b[1][1]) % m) % m; mat[1][0] = ((a[1][0] * b[0][0]) % m + (a[1][1] * b[1][0]) % m) % m; mat[1][1] = ((a[1][0] * b[0][1]) % m + (a[1][1] * b[1][1]) % m) % m; return mat; } ll fib(ll N,ll m){ /* ll a[2][2] = { {1 , 1}, {1 , 0} }; ll b[2][2] = { {1 , 0}, 0 , 1} }; */ auto a = MAT(2, vector(2)); auto b = MAT(2, vector(2)); a[0][0] = 1; a[0][1] = 1; a[1][0] = 1; a[1][1] = 0; b[0][0] = 1; b[0][1] = 0; b[1][0] = 0; b[1][1] = 1; ll ans = 0; while(N > 0){ if(N & 1){ b = mulmat(a,b,m); } a = mulmat(a,a,m); N /= 2; } //cout << b[0][0] << " " << b[0][1] << endl << b[1][0] << " " << b[1][1] << endl; return b[1][0]; } main(){ ll loop = 2000000016; ll N; cin >> N; //cout << fib(N,MOD) << endl; //cout << fib(N % loop,MOD) << endl; cout << fib(fib(N,loop),MOD) << endl; }