#include using namespace std; const vector dx = {0, 0, 1, -1}; const vector dy = {1, -1, 0, 0}; #define vec vector #define int long long #define double long double #define ll long long #define pii pair #define pq priority_queue #define all(V) begin(V),end(V) #define tple tuple template inline bool chmax(T &a, const U &b) { if (a < b) { a = b; return true; } return false; } template inline bool chmin(T &a, const U &b) { if (a > b) { a = b; return true; } return false; } #define nexper(Z) next_permutation(all(Z)) #define pb push_back #define rep(i, n) for (int i = 0; i < (int)(n); i++) #define req(i, x, n) for (int i = x; i < (int)(n); i++) #define rex(i, n) for (int i = 1; i <= (int)(n); i++) #define rey(i, x, n) for (int i = x; i <= (int)(n); i++) #define cleout(i) cout << fixed << setprecision(i) vector> mat_mul(vector> a, vector> b, ll mod) { // 行列乗算 int n = a.size(); vector> res(n, vector(n)); for (int i = 0; i < n; i++) { for (int j = 0; j < n; j++) { for (int k = 0; k < n; k++) { res[i][j] += a[i][k] * b[k][j]; res[i][j] %= mod; } } } return res; } vector> mat_pow(vector> a, ll b, ll mod) { // 行列累乗 int n = a.size(); vector> res(n, vector(n)); for (int i = 0; i < n; i++) res[i][i] = 1; while (b) { if (b & 1) res = mat_mul(res, a, mod); a = mat_mul(a, a, mod); b >>= 1; } return res; } signed main(){ ios::sync_with_stdio(false); cin.tie(nullptr); int n,m;cin>>n>>m; vec> mat={ {1,1},{1,0} }; if(n<=2){ cout<<1<> Z=mat_pow(mat,n-2,m); cout<