#C1118. Longest Palindrome Construction

    ID: 40467 Type: Default 1000ms 256MiB

Longest Palindrome Construction

Longest Palindrome Construction

Given a string s, determine the length of the longest palindrome that can be constructed using the letters of s. A palindrome is a string that reads the same backward as forward. You are allowed to rearrange the letters of the input string.

Hint: For each character with frequency count, you can contribute count - (count \mod 2) characters to the palindrome. If there is any character with an odd frequency, you can place one odd character in the middle. In mathematical form, the answer is computed as:

$$\text{result} = \sum_{c \in \text{chars}} \big(\text{count}(c) - (\text{count}(c) \bmod 2)\big) + \begin{cases} 1, & \text{if any } \text{count}(c) \bmod 2 = 1 \\ 0, & \text{otherwise} \end{cases}$$

Input is read from standard input and output is written to standard output.

inputFormat

The input consists of a single line containing the string s (which only contains English letters).

outputFormat

Output a single integer, representing the maximum length of a palindrome that can be constructed using the letters of s.

## sample
abccccdd
7