#include #include using namespace std; int main() { ios::sync_with_stdio(false); cin.tie(nullptr); int N; long M; cin>>N>>M; long a=0,b=1; for(int n=3;n<=N;n++) { long c=(a+b)%M; a=b; b=c; } cout<