#K74797. Rearrange to Palindrome

    ID: 34277 Type: Default 1000ms 256MiB

Rearrange to Palindrome

Rearrange to Palindrome

You are given a string s of length n and a non-negative integer k. Your task is to determine whether it is possible to rearrange the characters of s into a palindrome by performing at most k rearrangements. In other words, if the number of character pairs that must be rearranged to form a palindrome is at most k, print YES; otherwise, print NO.

The key observation is that a string can be rearranged into a palindrome if at most one character has an odd frequency count. More formally, if we let odd_count denote the number of characters with an odd frequency, then the condition is satisfied if and only if

[ \left\lfloor \frac{odd_count}{2} \right\rfloor \leq k ]

Note: The input is provided via stdin and output should be printed to stdout.

inputFormat

The input consists of two lines:

  1. The first line contains two integers n and k where n is the length of string s and k is the maximum number of allowed rearrangements.
  2. The second line contains the string s consisting only of lowercase English letters.

outputFormat

Output a single line containing either YES if it is possible to rearrange the string into a palindrome with at most k rearrangements, or NO otherwise.

## sample
6 2
aababc
YES