#C9946. Maximum Distinct Palindromic Substrings

    ID: 54095 Type: Default 1000ms 256MiB

Maximum Distinct Palindromic Substrings

Maximum Distinct Palindromic Substrings

You are given a string S. By rearranging the characters of S arbitrarily, determine the maximum number of distinct palindromic substrings that can be obtained. It turns out that, no matter how you rearrange the string, the maximum number of distinct palindromic substrings is equal to the length of the string, i.e. \(|S|\).

Explanation:

  • For example, if S = "aabb", then \(|S| = 4\) and the answer is 4.
  • If S = "abc", then \(|S| = 3\) and the answer is 3.
  • For S = "aaa", although the characters are the same, each character can be considered to form a palindrome. Hence, the answer is 3.

In summary, given any string S, simply output its length.

inputFormat

The input consists of a single line containing the string S. The string may include lowercase and uppercase letters. Note that the input is read from standard input (stdin).

Constraints:

  • 0 ≤ |S| ≤ 200000

outputFormat

Output a single integer representing the maximum number of distinct palindromic substrings that can be obtained by rearranging the letters of S. The result is equal to \(|S|\) and should be printed to standard output (stdout).

## sample
aabb
4