#include #include #define int long long #define endl "\n" #define all(n) n.begin(),n.end() #define rall(n) n.rbegin(),n.rend() #define rep(i, s, n) for (int i = s; i < (int)(n); i++) #define floatset(n) fixed<using vec=vector; templateusing min_queue=priority_queue,greater>; using ll = long long; using ld = long double; using pll = pair; using Graph = vector>; struct Edge1{ll to,cost;}; using WGraph = vec>; struct BellEdge{ll from,to,cost;}; using BGraph=vec; constexpr ll INF = 1e18; constexpr ll mod = 1000000007; constexpr ll MOD = 998244353; constexpr int dx[4]={1,0,-1,0}; constexpr int dy[4]={0,1,0,-1}; template bool chmin(T&a,T b){return a>b?a=b,true:false;} template bool chmax(T&a,T b){return a void Fill(A (&array)[N], const T &val){ fill( (T*)array, (T*)(array+N), val ); } vec>Mul(vec>&A,vec>&B,const int m){ vec>C(A.size(),vec(B.front().size())); for(int i=0;i>Pow(vec>A,int x,const int m){ vec>res(A.size(),vec(A.size())); for(int i=0;i0){ if(x&1)res=Mul(res,A,m); A=Mul(A,A,m); x>>=1; } return res; } signed main(){ int N,M; cin>>N>>M; vec>A(2,vec(2)); A[0][0]=1;A[0][1]=1; A[1][0]=1;A[1][1]=0; A=Pow(A,N-1,M); cout<