This task will exclusively concentrate only on the arrays where all elements equal 1 and/or 2.

Array *a* is *k*-period if its length is divisible by *k* and there is such array *b* of length *k*, that *a* is represented by array *b* written exactly <img align="middle" class="tex-formula" src="https://espresso.codeforces.com/e8f8616e518b67af73332593c4c73ae9f207dc04.png" style="max-width: 100.0%;max-height: 100.0%;"/> times consecutively. In other words, array *a* is *k*-periodic, if it has period of length *k*.

For example, any array is *n*-periodic, where *n* is the array length. Array [2, 1, 2, 1, 2, 1] is at the same time 2-periodic and 6-periodic and array [1, 2, 1, 1, 2, 1, 1, 2, 1] is at the same time 3-periodic and 9-periodic.

For the given array *a*, consisting only of numbers one and two, find the minimum number of elements to change to make the array *k*-periodic. If the array already is *k*-periodic, then the required value equals 0.
The first line of the input contains a pair of integers *n*, *k* (1 ≤ *k* ≤ *n* ≤ 100), where *n* is the length of the array and the value *n* is divisible by *k*. The second line contains the sequence of elements of the given array *a*<sub class="lower-index">1</sub>, *a*<sub class="lower-index">2</sub>, ..., *a*<sub class="lower-index">*n*</sub> (1 ≤ *a*<sub class="lower-index">*i*</sub> ≤ 2), *a*<sub class="lower-index">*i*</sub> is the *i*-th element of the array.
def entrada():
    entrada = input()
    ENTRADALIST = entrada.split(" ")
    n = int(ENTRADALIST[0])
    m = int(ENTRADALIST[1])
    return n, m

def stringToList():
    orig_L = str(input())
    orig_L = orig_L.replace(" ", "")
    orig_L = list(map(int, orig_L))
    new_L = list(orig_L)
    return new_L

def splitInChunk(lista, period):
    for i in range(0, len(lista), period):
        yield lista[i:i + period]

def numberDifferences(lista, period):
    differences = []
    for j in range(period):
        first_ind_list = []
        ones = 0
        twos = 0
        counter = 0
        
        for i in range(len(lista)):
            first_ind_list.append(lista[i][j])
        
        
        for c in first_ind_list:
            if c == 1:
                ones = ones + 1
            elif c == 2:
                twos = twos + 1
            

        if ones > twos:
            for k in first_ind_list:
                if k != 1:
                    counter += 1
            differences.append(counter)
        elif twos > ones:
            for k in first_ind_list:
                if k != 2:
                    counter += 1
            differences.append(counter)
    
    return differences

def minimumChanges(lista):
    key = max(lista)
    if key > 0:
        result = lista.count(key)
        print(result)
    else:
        print(0)
    return None

n, k = entrada()
original_list = stringToList()
list_in_chunks = list(splitInChunk(original_list, k))
differences = numberDifferences(list_in_chunks, k)
minimumChanges(differences)

	  			   		   		  	  	    		 		