#K76872. K-Distinct Palindrome Rearrangement

    ID: 34739 Type: Default 1000ms 256MiB

K-Distinct Palindrome Rearrangement

K-Distinct Palindrome Rearrangement

You are given a string ( s ) and an integer ( k ). Your task is to determine whether it is possible to rearrange the characters of ( s ) to form a palindrome that contains exactly ( k ) distinct characters.

Remember that a palindrome is a string that reads the same forwards and backwards. For a string to be rearranged into a palindrome, the frequency of each character must allow it – at most one character may appear an odd number of times (this one, if it exists, would be placed in the middle of the palindrome).

The distinct characters of the palindrome are exactly the distinct characters of the original string, so your solution must check that the number of unique characters in ( s ) equals ( k ) and that a palindromic rearrangement is possible.

inputFormat

The input is read from stdin and consists of two lines.
The first line contains the string ( s ) (only lowercase or uppercase alphabet letters).
The second line contains an integer ( k ).

outputFormat

Print to stdout a single line: either 'True' if it is possible to rearrange ( s ) into a palindrome having exactly ( k ) distinct characters, or 'False' otherwise.## sample

aabbcc
3
True