#include <bits/stdc++.h>   using namespace std;   const int N = 120000 + 10;   const double PI = acos(-1);   pair<double, double> operator+(pair<double, double> a, pair<double, double> b) {     return make_pair(a.first + b.first, a.second + b.second);   }   pair<double, double> operator-(pair<double, double> a, pair<double, double> b) {     return make_pair(a.first - b.first, a.second - b.second);   }   pair<double, double> operator*(pair<double, double> a, pair<double, double> b) {     return make_pair(a.first * b.first - a.second * b.second,                      a.first * b.second + a.second * b.first);   }   pair<double, double> operator/(pair<double, double> a, double t) {     return make_pair(a.first / t, a.second / t);   }   int rev[N], lim;   pair<double, double> w[N];   void initrever(int n, int &lim) {     lim = 1;     for (; lim < n; lim <<= 1)       ;     for (int i = 1; i < lim; i++) {       rev[i] = (rev[i >> 1] >> 1);       if (i & 1) rev[i] |= (lim >> 1);     }     for (int i = 0; i < lim; i++) {       double t = 2 * PI * i / lim;       w[i] = make_pair(cos(t), sin(t));     }     return;   }   void FFT(vector<pair<double, double> > &a, int t) {     int lim = a.size();     if (t < 0) {       for (int i = 1; i < lim; i++) {         if (i < (lim - i)) swap(a[i], a[lim - i]);       }     }     for (int i = 0; i < lim; i++)       if (i < rev[i]) swap(a[i], a[rev[i]]);     for (int i = 2; i <= lim; i <<= 1) {       for (int j = 0; j < lim; j += i) {         for (int k = 0; k < (i >> 1); k++) {           pair<double, double> first = a[j + k],                                second = a[j + k + (i >> 1)] * w[lim / i * k];           a[j + k] = (first + second);           a[j + k + (i >> 1)] = (first - second);         }       }     }     if (t < 0) {       for (int i = 0; i < lim; i++) a[i] = a[i] / lim;     }     return;   }   vector<pair<double, double> > f[2];   int n, a, p;   double reduce(double first) {     long long tmp = llround(first);     tmp %= p;     return (double)tmp;   }   void add1() {     swap(f[0], f[1]);     for (int i = 0; i <= 1; i++) {       for (int j = n; j >= 1; j--) {         f[i][j].first = reduce(f[i][j].first + f[i][j - 1].first);       }     }     f[1][1].first = reduce(f[1][1].first + 1);     return;   }   void put(vector<pair<double, double> > v) {     for (int i = 0; i < (int)v.size(); i++) printf( %lf  , v[i].first);     printf(  n );     return;   }   void pro2(int v) {     FFT(f[0], 1), FFT(f[1], 1);     for (int i = 0; i < lim; i++) {       pair<double, double> first =           f[v & 1][i] * (f[0][i] + f[1][i]) + f[0][i] + f[v & 1][i];       pair<double, double> second =           f[(v & 1) ^ 1][i] * (f[0][i] + f[1][i]) + f[1][i] + f[(v & 1) ^ 1][i];       f[0][i] = first, f[1][i] = second;     }     FFT(f[0], -1), FFT(f[1], -1);     for (int i = 0; i <= 1; i++) {       for (int j = 0; j <= n; j++) {         f[i][j].first = reduce(f[i][j].first);         f[i][j].second = 0;       }       for (int j = n + 1; j < lim; j++) f[i][j] = make_pair(0, 0);     }     return;   }   vector<int> num;   int main() {     scanf( %d%d%d , &n, &a, &p);     initrever(n * 2 + 1, lim);     f[0].resize(lim), f[1].resize(lim);     for (int no = a; no > 1; no /= 2) {       num.push_back(no);     }     num.push_back(1);     reverse(num.begin(), num.end());     f[1][1].first = 1;     int ans = 0;     for (int i = 0; i < (int)num.size() - 1; i++) {       for (int j = 1; j <= n; j += 2) {         ans = (ans + llround(f[1][j].first)) % p;       }       pro2(num[i]);       if (num[i] * 2 < num[i + 1]) add1();     }     printf( %d n , ans);     return 0;   }