Problem:
Score : 1200 points

Problem Statement

In Republic of AtCoder, Snuke Chameleons (Family: Chamaeleonidae, Genus: Bartaberia) are very popular pets.
Ringo keeps N Snuke Chameleons in a cage.

A Snuke Chameleon that has not eaten anything is blue. It changes its color according to the following rules:

A Snuke Chameleon that is blue will change its color to red when the number of red balls it has eaten becomes strictly larger than the number of blue balls it has eaten.

A Snuke Chameleon that is red will change its color to blue when the number of blue balls it has eaten becomes strictly larger than the number of red balls it has eaten.

Initially, every Snuke Chameleon had not eaten anything. Ringo fed them by repeating the following process K times:

Grab either a red ball or a blue ball.

Throw that ball into the cage. Then, one of the chameleons eats it.

After Ringo threw in K balls, all the chameleons were red. We are interested in the possible ways Ringo could have thrown in K balls. How many such ways are there? Find the count modulo 998244353. Here, two ways to throw in balls are considered different when there exists i such that the color of the ball that are thrown in the i-th throw is different.

Constraints

1 \leq N,K \leq 5 \times 10^5

N and K are integers.

Input

Input is given from Standard Input in the following format:

N K

Output

Print the possible ways Ringo could have thrown in K balls, modulo 998244353.

Sample Input 1

2 4

Sample Output 1

7

We will use R to represent a red ball, and B to represent a blue ball. There are seven ways to throw in balls that satisfy the condition: BRRR, RBRB, RBRR, RRBB, RRBR, RRRB and RRRR.

Sample Input 2

3 7

Sample Output 2

57

Sample Input 3

8 3

Sample Output 3

0

Sample Input 4

8 10

Sample Output 4

46

Sample Input 5

123456 234567

Sample Output 5

857617983

Solution in C++14 (GCC 5.4.1) (judge verdict: Accepted)

#include <bits/stdc++.h>
using namespace std;
constexpr int P = 998244353;
void inc(int &a, int b) {(a += b) >= P ? a -= P : 0;}
int dif(int a, int b) {return (a -= b) < 0 ? a += P : a;}
int power(int base, int exp) {
    int result = 1;
    while (exp > 0) {
        if (exp & 1)
            result = 1LL * result * base % P;
        base = 1LL * base * base % P;
        exp >>= 1;
    }
    return result;
}
int main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    int n, k;
    cin >> n >> k;
    int ans = 0;
    vector<int> factorial(k + 1), inv_factorial(k + 1);
    factorial[0] = 1;
    for (int i = 1; i <= k; ++i)
        factorial[i] = 1LL * factorial[i - 1] * i % P;
    inv_factorial[k] = power(factorial[k], P - 2);
    for (int i = k; i >= 1; --i)
        inv_factorial[i - 1] = 1LL * inv_factorial[i] * i % P;
    auto binom = [&](int n, int m)->int {
        if (m < 0 || n < m)
            return 0;
        return 1LL * factorial[n] * inv_factorial[m] % P * inv_factorial[n - m] % P;
    };
    auto countPath = [&](int x, int y, int t) {
        if (t < 0)
            return 0;
        return dif(binom(x + y, x), binom(x + y, x + t));
    };
    for (int red = 0; red <= k; ++red) {
        int blue = k - red;
        if (red < blue)
            continue;
        if (red == blue)
            inc(ans, countPath(red, blue - 1, red - n + 1));
        else
            inc(ans, countPath(red, blue, red - n + 1));
    }
    cout << ans << endl;
    return 0;
}