Under construction

Still being built. Things may change

K-Goodness String

Interview

Memory limit1024 MB

Summary
Given a string, find the minimum number of character changes needed so exactly K mirrored position pairs differ.
Level

Easy3 of 10

Topics
String, Greedy, Implementation, Math
Solved
No attempts yet

Problem

Charles defines the goodness score of a string as the number of indices ii with 1≤i≤N/21 \le i \le N/2 (1-indexed) such that Si≠SN−i+1S_i \ne S_{N-i+1}. For example, the string CABABC has a goodness score of 2 since S2≠S5S_2 \ne S_5 and S3≠S4S_3 \ne S_4.

Charles gave Ada a string SS of length NN consisting of uppercase letters and asked her to convert it into a string with a goodness score of KK. In one operation, Ada can change any character in the string to any uppercase letter. Find the minimum number of operations required to transform the given string into a string with goodness score equal to KK.

Input

The first line of the input gives the number of test cases, TT. TT test cases follow.

The first line of each test case contains two integers NN and KK. The second line of each test case contains a string SS of length NN, consisting of uppercase letters.

Output

For each test case, output one line containing Case #x: y, where xx is the test case number (starting from 1) and yy is the minimum number of operations required to transform the given string SS into a string with goodness score equal to KK.

Constraints

  • 1≤T≤1001 \le T \le 100.
  • 0≤K≤N/20 \le K \le N/2.

Hint

In sample case 1, the given string already has a goodness score of 1. Therefore the minimum number of operations required is 0.

In sample case 2, one option is to change the character at index 1 to B in order to have a goodness score of 2. Therefore, the minimum number of operations required is 1.

Examples1

  1. Example 1

    Input
    2
    5 1
    ABCAA
    4 2
    ABAA
    
    Expected output
    Case #1: 0
    Case #2: 1