#include #define rep(i,n) for(int i=0; i; typedef long long ll; const ll INF = 100000000000000000LL; int main(void) { int N, M; cin >> N >> M; int pre, prepre; rep(i, N) { if(i == 0) prepre = 0; else if(i == 1) pre = 1; else { int tmp = (prepre + pre) % M; prepre = pre; pre = tmp; } } cout << pre << endl; }