#include<bits/stdc++.h>
// #define int long long
using namespace std;

const int M = 2650;
const int N = 1350;

int md;

inline void add(int& a, int& b) {
	a += b;
	if (a >= md) a -= md;
}

int32_t main(){
    ios_base::sync_with_stdio(false);
    cin.tie(0);
   	
   	int n;
   	cin >> n >> md;
   	vector<vector<vector<int>>> dp(n + 1, vector<vector<int>>(M, vector<int>(3, 0)));
   	dp[0][N][0] = 1;
   	for (int i = 0; i < n; ++i) {
   		for (int gap = 51; gap < M - 51; ++gap) {
   			for (int x = 0; x <= i; ++x) {
   				for (int y = 0; y <= i; ++y) {
   					if (x == y) {
   						for (int ok = 0; ok <= 2; ++ok) {
   							add(dp[i + 1][gap][ok], dp[i][gap][ok]);
   						}
   					} else {
   						int sum = 0;
   						for (int ok = 0; ok <= 2; ++ok) {
   							add(sum, dp[i][gap][ok]);
   						}
   						add(dp[i + 1][gap + (x - y)][(x > y) + 1], sum);
   					}
   				}
   			}
   		}
   	}
   	int ans = 0;
   	for (int gap = N + 1; gap < M; ++gap) {
   		add(ans, dp[n][gap][1]);
   	}
   	cout << ans;
   	
   	
    return 0;
}