#include <bits/stdc++.h>
using namespace std;
const int mod = 1e9 + 7;
int n, k, a[105], i, j, sum, cnt, temp;
int main() {
  scanf("%d %d", &n, &k);
  for (i = 0; i < n; i++) {
    scanf("%d", &a[i]);
  }
  sum = 0;
  for (i = 0; i < k; i++) {
    cnt = 0;
    for (j = i; j < n; j += k) {
      if (a[j] == 1) cnt++;
    }
    temp = n / k - cnt;
    sum += min(cnt, temp);
  }
  printf("%d\n", sum);
}
