// 蟻本を丸写し. // 行列を用いた繰り返し二乗法でフィボナッチ数をlognで処理. #include #include using namespace std; typedef long long ll; typedef vector vec; typedef vector mat; ll mod = 1000000007; mat mul(mat &A, mat &B){ mat C(A.size(), vec(B[0].size())); for(int i = 0; i < A.size(); i++){ for(int k = 0; k < B.size(); k++){ for(int j = 0; j < B[0].size(); j++){ C[i][j] = (C[i][j] + A[i][k] * B[k][j]) % mod; } } } return C; } mat pow(mat A, ll n){ mat B(A.size(), vec(A.size())); for(int i = 0; i < A.size(); i++){ B[i][i] = 1ll; } while(n > 0){ if(n & 1) B = mul(B, A); A = mul(A, A); n >>= 1; } return B; } int main(){ ll n; cin >> n; mat A(2, vec(2)); A[0][0] = 1; A[0][1] = 1; A[1][0] = 1; A[1][1] = 0; A = pow(A, n); ll a = A[0][0] % mod; ll b = A[1][0] % mod; cout << (a*b)%mod << endl; return 0; }