ll a[6d6],n,m;{a[2]=1;rd(n,m);a[3..n]=(a[1..]+a[2..])%m;wt(a[n]);}