C++#include<bits/stdc++.h>
using namespace std;
#define ll long long
//A*B=C A的列数与 B的行数相等,为 n
//c(i,j)=a(i,1)*b(1,j)+...+a(i,n)*b(n,j) 时间复杂度 O(n^3)
//矩阵乘法没有交换律,有结合律
//a(i,i)=1,其余为 0,则 A*B=B
//f(n)=f(n-1)+f(n-2) 斐波那契数列
//[f(n),f(n-1)]=[f(n-1),f(n-2)]*[(1,1),(1,0)]
//f(n)=[1,1]*([(1,1),(1,0)]^(n-2))
const int N=510,n=2;
struct node
{
ll v[N][N];
node()
{
memset(v,0,sizeof(v));
}
node operator *(const node &b)const
{
node c;
for(int i=1;i<=n;i++)
{
for(int k=1;k<=n;k++)
{
if(!v[i][k]) continue;
for(int j=1;j<=n;j++)
c.v[i][j]=(c.v[i][j]+v[i][k]*b.v[k][j]%mod)%mod;
}
}
return c;
}
}bs;
node ksm(node a,ll b)
{
node res;
for(int i=1;i<=n;i++) res.v[i][i]=1;
while(b)
{
if(b&1) res=res*a;
a=a*a;
b>>=1;
}
return res;
}
int main()
{
//斐波那契数列 O(n^3*logk)
cin>>k;
bs.v[1][1]=bs.v[1][2]=bs.v[2][1]=1;
node ans;
ans.v[1][1]=ans.v[1][2]=1;
ans=ans*ksm(bs,k-2);
cout<<ans.v[1][1];
return 0;
}