1 #include <bits/stdc++.h>
2
3 using namespace std;
4
5 #define REP(i, a, b) for (int i = (a), i##_end_ = (b); i <= i##_end_; ++i)
6 #define DWN(i, a, b) for (int i = (a), i##_end_ = (b); i >= 0; --i)
7 #define mset(a, b) memset(a, b, sizeof(a))
8 const int maxn = 505, maxc = 1<<8;
9 typedef long long LL;
10 int n, MOD;
11 int f[maxc+10][maxc+10], dp[maxc+10][maxc+10][2];
12 struct Node
13 {
14 int s, p;
15 Node (int s = 0, int p = 0): s(s), p(p) {}
16 bool operator < (const Node &AI) const { return p < AI.p; }
17 }d[maxn];
18 int prime[8] = {2, 3, 5, 7, 11, 13, 17, 19};
19
20 void calc(int x)
21 {
22 int xx = x;
23 REP(i, 0, 7)
24 if (x%prime[i] == 0)
25 {
26 d[xx].s |= (1<<i);
27 while (x%prime[i] == 0) x/= prime[i];
28 }
29 d[xx].p = x;
30 }
31
32 int main()
33 {
34 scanf("%d %d", &n, &MOD);
35 REP(i, 2, n) calc(i);
36 sort(d+2, d+n+1), mset(f, 0), f[0][0] = 1;
37 REP(i, 2, n)
38 {
39 if (i == 2 || d[i].p == 1 || d[i].p != d[i-1].p)
40 REP(j, 0, maxc-1)
41 REP(k, 0, maxc-1)
42 dp[j][k][0] = dp[j][k][1] = f[j][k];
43 DWN(j, maxc-1, 0)
44 DWN(k, maxc-1, 0)
45 {
46 if ((d[i].s&k) == 0) dp[j|d[i].s][k][0] = (dp[j|d[i].s][k][0]+dp[j][k][0])%MOD;
47 if ((d[i].s&j) == 0) dp[j][k|d[i].s][1] = (dp[j][k|d[i].s][1]+dp[j][k][1])%MOD;
48 }
49 if (i == n || d[i].p == 1 || d[i].p != d[i+1].p)
50 REP(j, 0, maxc-1)
51 REP(k, 0, maxc-1)
52 f[j][k] = ((LL)dp[j][k][0]+dp[j][k][1]-f[j][k])%MOD;
53 }
54 int ans = 0;
55 REP(i, 0, maxc-1)
56 REP(j, 0, maxc-1)
57 if ((i&j) == 0)
58 ans = (ans+f[i][j])%MOD;
59 printf("%d\n", (ans+MOD)%MOD);
60 return 0;
61 }