6517: ABC234 —— F - Reordering
[Creator : ]
Description
Given is a string $S$. How many different strings can be obtained as a permutation of a non-empty, not necessarily contiguous subsequence of $S$?
Since the count can be enormous, print it modulo $998244353$.
Since the count can be enormous, print it modulo $998244353$.
Input
Input is given from Standard Input in the following format:
$S$
$S$
Output
Print the number of different strings that can be obtained as a permutation of a subsequence of $S$, modulo $998244353$.
Constraints
$S$ is a string of length $1$ and $5000$ (inclusive) consisting of lowercase English letters.
Sample 1 Input
aab
Sample 1 Output
8
There are $8$ different strings that can be obtained as a permutation of a subsequence of $S:\ \text{a, b, aa, ab, ba, aab, aba, baa}$.
Sample 2 Input
aaa
Sample 2 Output
3
Sample 3 Input
abcdefghijklmnopqrstuvwxyz
Sample 3 Output
149621752