#K70982. Longest Palindrome

    ID: 33429 Type: Default 1000ms 256MiB

Longest Palindrome

Longest Palindrome

Given a string s and its length n, determine the length of the longest palindrome that can be constructed using a subset of the characters in s.

A palindrome is a string that reads the same forwards and backwards. In order to construct the palindrome, you can use each character as many times as it appears in s. Characters that occur an even number of times can be fully used, while for those that occur an odd number of times, all but one occurrence can be symmetrically used. If there is at least one character with an odd count, one additional character may be placed in the center of the palindrome.

The task is to compute and output the maximum length of such a palindrome.

inputFormat

The input is provided via standard input (stdin) and consists of two lines:

  • The first line contains an integer n representing the length of the string.
  • The second line contains the string s.

outputFormat

Output via standard output (stdout) a single integer representing the length of the longest palindrome that can be formed using the characters of s.

## sample
7
abccccdd
7