#include <bits/stdc++.h>   using namespace std;   using ll = long long;   using ld = long double;   using D = double;   using uint = unsigned int;   template <typename T>   using pair2 = pair<T, T>;   const long double pi = acos((ld)-1.0);   const int maxn = 1 << 16;   complex<double> oddc[maxn], evenc[maxn], tmp[maxn];   complex<double> w[maxn], invw[maxn];   ll odd[maxn], even[maxn];   int oldodd[maxn], oldeven[maxn];   int btr[maxn];   int n, A, mod;   int st2;   int answer;   inline int bitrev(int x) { return btr[x]; }   void fft(complex<double> *a, int n, complex<double> *w, complex<double> *res) {     for (int i = 0; i < n; i++) res[bitrev(i)] = a[i];     for (int len = 2; len <= n; len *= 2) {       int step = n / len;       for (int i = 0; i < n; i += len) {         int curw = 0;         for (int j = 0; j < len / 2; j++) {           complex<double> x = res[i + j];           complex<double> y = res[i + len / 2 + j] * w[curw];           res[i + j] = x + y;           res[i + len / 2 + j] = x - y;           curw += step;         }       }     }   }   void preparefft(int n) {     for (int i = 0; i < n; i++) {       int cur = i;       for (int j = 0; (1 << j) < n; j++) {         btr[i] = (btr[i] << 1) | (cur & 1);         cur >>= 1;       }     }     for (int i = 0; i < n; i++) {       w[i] = complex<double>(cos(2 * pi / n * i), sin(2 * pi / n * i));       invw[i] = w[i];     }     reverse(invw + 1, invw + n);   }   void conv(ll *from, complex<double> *to) {     for (int i = n + 1; i < st2; i++) tmp[i] = 0;     for (int i = 0; i <= n; i++) tmp[i] = from[i];     fft(tmp, st2, w, to);   }   void convback(complex<double> *from, ll *to) {     fft(from, st2, invw, tmp);     for (int i = 0; i < st2; i++) tmp[i] /= st2;     for (int i = 0; i <= n; i++) {       to[i] = (ll)(tmp[i].real() + 0.5);       assert(abs(tmp[i].imag()) < 0.1);     }   }   void addans() {     for (int i = 1; i <= n; i += 2) answer = (answer + odd[i]) % mod;   }   void go(int A) {     if (A == 1) {       even[0] = 1;       odd[0] = 0;       odd[1] = 1;       addans();       return;     }     go(A / 2);     for (int i = 0; i <= n; i++) oldodd[i] = odd[i];     for (int i = 0; i <= n; i++) oldeven[i] = even[i];     conv(even, evenc);     conv(odd, oddc);     for (int i = 0; i < st2; i++) {       if ((A / 2) % 2 == 0) {         tie(oddc[i], evenc[i]) =             make_pair((oddc[i] + evenc[i]) * oddc[i],                       (oddc[i] + evenc[i]) * (evenc[i] - (complex<double>)1));       } else {         tie(evenc[i], oddc[i]) =             make_pair((oddc[i] + evenc[i]) * oddc[i],                       (oddc[i] + evenc[i]) * (evenc[i] - (complex<double>)1));       }     }     convback(oddc, odd);     convback(evenc, even);     for (int i = n + 1; i <= 2 * n; i++) {       odd[i] = 0;       even[i] = 0;     }     for (int i = 0; i <= n; i++) {       odd[i] = (odd[i] + oldodd[i]) % mod;       even[i] = (even[i] + oldeven[i]) % mod;     }     if (A % 2 == 1) {       for (int i = n; i >= 1; i--) {         odd[i] = (odd[i] + odd[i - 1] + even[i - 1]) % mod;       }     }     addans();   }   int main() {     cin >> n >> A >> mod;     if (A == 1) {       cout << 0 << endl;       return 0;     }     st2 = 0;     while ((1 << st2) <= n) st2++;     st2++;     st2 = 1 << st2;     preparefft(st2);     go(A / 2);     cout << answer << endl;     return 0;   }