#include <bits/stdc++.h>
using namespace std;
const int NMAX = 101;
int N, K, V[NMAX];
int makeKArray() {
  int repetitions = N / K;
  int counter1, counter2, result = 0;
  for (int i = 0; i < K; i++) {
    counter1 = 0;
    counter2 = 0;
    for (int j = 0; j < repetitions; j++) {
      if (V[i + j * K] == 1) {
        counter1++;
      } else {
        counter2++;
      }
    }
    result += min(counter1, counter2);
  }
  return result;
}
int main() {
  cin >> N >> K;
  for (int i = 0; i < N; i++) {
    cin >> V[i];
  }
  cout << makeKArray();
  return 0;
}
