#include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #define N 1000 #define re(i,n) for(int i=0;i<(n);i++) #define rep(i,a,b) for(int i=(a);i<(b);i++) #define fe(i,n,f) for_each(i,n,f) #define bw(a,b,c) (((a)<=(b))&&((b)<=(c))) using namespace std; typedef long long ll; typedef unsigned long long ull; int main(void){ unsigned int n,m; cin>>n>>m; unsigned int a=0,b=1; rep(i,2,n){ unsigned int k=(b+a)%m; a=b; b=k; } cout<