#include using namespace std; using ll=long long; int main(){ int N,M; cin>>N>>M; ll a=0,b=1; while(--N){ swap(a,b); (b+=a)%=M; } cout<