cho.sh
Notes
Loading...

Make a Periodic String

Time limit

2s

Memory limit

128 MB

Problem

Sejun is a biologist, so he often works with DNA strings. One day, he became tired of looking at a long DNA string and wanted to express it in a simpler periodic form.

For a string of length LLL, a positive integer PPP is a period length if, for every integer iii with 0≤i≤L−P−10 \le i \le L-P-10≤i≤L−P−1, the character at position iii is the same as the character at position i+Pi+Pi+P. For example, CATCATC, CATCAT, ACTAC, and ACT all have period length 333.

Given a DNA string, change as few characters as possible so that it becomes a periodic string whose period length is at most MMM. Find the minimum number of characters that must be changed.

Input

The first line contains MMM. The value of MMM is at most the length of the string.

The second line contains the DNA string. The string consists only of A, C, G, and T, and its length is at most 300030003000.

Output

Print the minimum number of characters that must be changed.