#include<bits/stdc++.h>
using namespace std;
#define M_PI  3.1415926535
#define ll long long
#define ld long double
#define all(a) a.begin(),a.end()
#define Summon_Tourist ios::sync_with_stdio(false);cin.tie(0);
ll gcd(ll a , ll b) { return b==0?a: gcd( b, a%b); }
ll lcm(ll a , ll b) { return a/gcd(a,b) * b ; }
ll inf = 998244353;
ll modexp( ll base ,ll power)
 {
     if( power == 0  ) return 1;
     if( power & 1) return base*modexp( base , power-1 )%inf;
     return modexp(base*base%inf,power/2);
 }

 int main()
{
  Summon_Tourist
  //freopen("input.txt" , "r" , stdin ) ;
  ll t = 1;
  //cin>>t;
  while(t--)
  {
      ll n,k; cin>>n>>k;
      vector<ll> a(2*n+1,0);
      for( ll i = 2 ; i<=2*n ; i++ ){
        if( i<=n ) a[i] = i - 1 ;
        else{
            a[i] = ( i-1 ) - 2*(i - n - 1) ;
        }
      }
      if ( k<0 ) k *= -1 ;

      ll ans = 0 ;
      for( ll i = k+2 ; i<=2*n ; i++ ){

        ans += ( a[i] * a[i-k] ) ;


      }
      cout<<ans;

  }
  return 0;

}

#include <iostream>
#include <cstdio>
using namespace std;
const int N=5010,mod=998244353;
int fp[N][N],res[N];
int main()
{
	int n,m,ans=0;
	scanf("%d%d",&n,&m);
	for(int i=0;i<=m;i++)
	{
		fp[i][0]=1;
		for(int j=1;j<=n;j++)
		  fp[i][j]=1ll*fp[i][j-1]*i%mod;
	}
	for(int d=1;d<=n-1;d++)
	{
		for(int x=1;x<=m;x++)
			res[d]=(res[d]+fp[m-x][d-1])%mod;
		res[d]=1ll*res[d]*fp[m][n-d-1]%mod;
	}
	ans=1ll*n*fp[m][n]%mod;
	for(int i=1;i<=n;i++)
		for(int j=1;j<i;j++)
			ans=(ans-res[i-j])%mod;
	printf("%d\n",(ans+mod)%mod);
	return 0;
}