#include <bits/stdc++.h>
using namespace std;
const int mod = 998244353;
const int N = 3010;
int f[N][N];
int main(){
#ifndef ONLINE_JUDGE
	freopen("E:\\in.txt","r", stdin);
#endif
	int n, k;
	cin >> n >> k;
	f[0][0] = 1;
	for(int i = 1; i <= n; i++){
		for(int j = n; j >= 1; j--){
			f[i][j] = f[i-1][j-1];
			if(i >= 2 * j)
				f[i][j] = (f[i][j] + f[i][2*j]) % mod; 
		} 
	}
	cout << f[n][k] << endl;
}
#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
#define rep(i, n) for(ll i = 0; i < (n); ++i)
#define FOR(i, m, n) for(ll i = m; i < (n); i++)
#define all(x) (x).begin(),(x).end()
using namespace std;
typedef long long ll;
using vi = vector<int>;
using vii = vector<vi>;
using pii = pair<int, int>; 
using vl = vector<ll>;
using vll = vector<vl>;
using pll = pair<ll, ll>;

const ll MOD = 1000000007;

//a^n mod
ll modpow(ll a, ll n){
    ll res = 1;
    while(n > 0){
        if(n & 1) res = res * a % MOD;
        a = a * a % MOD;
        n >>= 1;
    }
    return res;
}

int main() {
    ll N, P;
    cin>>N>>P;

    ll ans = (P-1) * modpow(P-2, N-1) % MOD;
    cout << ans;
}   