#include using namespace std; int fib(int n, int m){ int a=0,b=1,c; for(int i=3;i<=n;i++){ c=(a+b)%m; a=b; b=c; } return c; } int main() { int n,m; cin >> n >> m; cout << fib(n,m) << endl; return 0; }