#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; a=b%m; b=c%m; } return c; } int main() { int n,m; cin >> n >> m; cout << fib(n,m) << endl; return 0; }