#K82487. Longest Palindrome

    ID: 35986 Type: Default 1000ms 256MiB

Longest Palindrome

Longest Palindrome

Given a string s, determine the length of the longest palindrome that can be built using the characters from s. In a palindrome, all characters must appear in a symmetric order. In other words, count the pairs of characters (each pair contributes 2 to the length), and if there is at least one character with an odd frequency, you can place one extra character in the center.

The mathematical formulation can be expressed as:

\[ \text{result} = 2 \times \left\lfloor \frac{\text{count}}{2} \right\rfloor + \begin{cases} 1, & \text{if any character has an odd count}\\ 0, & \text{otherwise} \end{cases} \]

inputFormat

The input consists of a single line containing the string s. The string may be empty and can include uppercase, lowercase letters, or other characters.

outputFormat

Output a single integer representing the length of the longest palindrome that can be built with the characters from s.

## sample
abccccdd
7