Reordering

AtCoder
IDabc234_f
Time2000ms
Memory256MB
Difficulty
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$. ## Constraints * $S$ is a string of length $1$ and $5000$ (inclusive) consisting of lowercase English letters. ## Input Input is given from Standard Input in the following format: $S$ [samples]
Samples
Input #1
aab
Output #1
8

There are $8$ different strings that can be obtained as a permutation of a subsequence of $S$: `a`, `b`, `aa`, `ab`, `ba`, `aab`, `aba`, `baa`.
Input #2
aaa
Output #2
3
Input #3
abcdefghijklmnopqrstuvwxyz
Output #3
149621752

Be sure to print the count modulo $998244353$.
API Response (JSON)
{
  "problem": {
    "name": "Reordering",
    "description": {
      "content": "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 $",
      "description_type": "Markdown"
    },
    "platform": "AtCoder",
    "limit": {
      "time_limit": 2000,
      "memory_limit": 262144
    },
    "difficulty": "None",
    "is_remote": true,
    "is_sync": true,
    "sync_url": null,
    "sign": "abc234_f"
  },
  "statements": [
    {
      "statement_type": "Markdown",
      "content": "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$?\nSince the count can be enormous, print it modulo $...",
      "is_translate": false,
      "language": "English"
    }
  ]
}
Full JSON Raw Segments