#C8698. Longest Palindrome Length

    ID: 52708 Type: Default 1000ms 256MiB

Longest Palindrome Length

Longest Palindrome Length

You are given a string s consisting of English letters. Your task is to determine the length of the longest palindrome that can be constructed by using any subset of the characters of s.

A palindrome is a string that reads the same forwards and backwards. One way to think about the problem is to count the frequency of each character. For each character with even count, you can use all of them; for characters with odd counts, you can use all but one, and if there is at least one odd count, you can place a single character in the middle. Formally, if you have character counts \(c_i\), then the answer is given by:

\[ \text{answer} = \sum_{i} \left(c_i - (c_i \bmod 2)\right) + \begin{cases} 1, & \text{if at least one } c_i \text{ is odd}\\ 0, & \text{otherwise} \end{cases} \]

inputFormat

The input consists of a single line which contains the string s.

outputFormat

Output a single integer, the length of the longest palindrome that can be built with the given characters.

## sample
abccccdd
7

</p>