## https://yukicoder.me/problems/no/1897 MOD = 998244353 def my_pow(k, n): if k > 0: return pow(k, n, MOD) else: return 0 def main(): N, K = map(int, input().split()) answer = 0 for k in reversed(range(1, K + 1)): # 一番大きい値がkの場合 ans1 = my_pow(k, N) ans1 -= my_pow(k - 1, N) ans1 %= MOD ans1 -= (N * my_pow(k - 1, N - 1)) % MOD ans1 %= MOD # 一番大きい値がkより大きい場合 ans2 = my_pow(k, N - 1) ans2 -= my_pow(k - 1, N - 1) ans2 %= MOD ans2 *= (K - k) ans2 %= MOD ans2 *= N ans2 %= MOD # print(f"k = {k}, ans1 = {ans1}, ans2 = {ans2}") ans = (ans1 + ans2) % MOD answer += (ans * k) % MOD answer %= MOD print(answer) if __name__ == "__main__": main()