← Home
use std::io;

const MOD: i64 = 998244353;

// Function for modular exponentiation: (base^exp) % MOD
fn power(mut base: i64, mut exp: i64) -> i64 {
    let mut res = 1;
    base %= MOD;
    while exp > 0 {
        if exp % 2 == 1 {
            res = (res * base) % MOD;
        }
        base = (base * base) % MOD;
        exp /= 2;
    }
    res
}

// Function for modular inverse using Fermat's Little Theorem
fn mod_inverse(n: i64) -> i64 {
    power(n, MOD - 2)
}

// Function to calculate nCr modulo MOD
fn nCr(n: i64, r: i64, fact: &[i64], inv_fact: &[i64]) -> i64 {
    if r < 0 || r > n {
        return 0;
    }
    fact[n as usize] * inv_fact[r as usize] % MOD * inv_fact[(n - r) as usize] % MOD
}

fn solve() {
    // 1. Reading input
    let mut input = String::new();
    io::stdin().read_line(&mut input).expect("Failed to read line");
    let parts: Vec<i64> = input
        .trim()
        .split_whitespace()
        .map(|x| x.parse().expect("Not an integer"))
        .collect();

    if parts.len() < 2 {
        println!("Please provide n and m");
        return;
    }

    let n = parts[0];
    let m = parts[1];

    // Edge case: If n < 2, the term (n-2) is negative or zero,
    // and 2^(n-2) might be invalid depending on context.
    // Assuming n >= 2 for the formula to make sense.
    if n < 2 {
        println!("0");
        return;
    }

    // 2. Precompute Factorials (Standard CP approach)
    // We need factorials up to max(m, n) generally.
    // Assuming m is the upper bound for C(m, n-1).
    let max_val = m as usize + 5; 
    let mut fact = vec![0; max_val];
    let mut inv_fact = vec![0; max_val];

    fact[0] = 1;
    inv_fact[0] = 1;

    for i in 1..max_val {
        fact[i] = (fact[i - 1] * i as i64) % MOD;
    }

    // Precompute inverses
    inv_fact[max_val - 1] = mod_inverse(fact[max_val - 1]);
    for i in (1..max_val - 1).rev() {
        inv_fact[i] = (inv_fact[i + 1] * (i as i64 + 1)) % MOD;
    }

    // 3. Calculate terms
    // Term 1: C(m, n-1)
    let term1 = nCr(m, n - 1, &fact, &inv_fact);

    // Term 2: (n - 2)
    let term2 = (n - 2) % MOD;

    // Term 3: (2^(n-3))
    let pow_2 = power(2, n - 3);
    // Handle negative result from subtraction modulo P
    let term3 = (pow_2 + MOD) % MOD; 

    // 4. Final Result
    let res = term1 * term2 % MOD * term3 % MOD;

    println!("{}", res);
}

fn main() {
    // To handle large I/O buffers in CP, usually we'd use a specialized scanner,
    // but standard IO is fine for this example.
    solve();
}