#C5624. Longest Palindrome Length

    ID: 49294 Type: Default 1000ms 256MiB

Longest Palindrome Length

Longest Palindrome Length

Given a string s consisting of lowercase English letters, determine the length of the longest palindrome that can be constructed by rearranging its characters.

A palindrome is a string that reads the same forwards and backwards. In forming a palindrome, characters with even counts can be fully used, while for characters with odd counts, all but one can be paired. Thus, if there is at least one character with an odd count, one extra character can be used as the middle character.

Mathematically, if the frequency of a character c is \(f(c)\), then the total length of the longest palindrome can be computed as:

\( \sum_{c}\left\lfloor \frac{f(c)}{2} \right\rfloor \times 2 + \Bigl[\text{if any } f(c) \bmod 2 = 1 \Bigr] \)

inputFormat

The input consists of a single line containing the string s composed of lowercase English letters. The string may be empty.

outputFormat

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

## sample
abcb
3