#include <bits/stdc++.h>
int a[110], c[110];
using namespace std;
int main() {
  int m, n, i, j, l, ans = 0, k, kk;
  scanf("%d%d", &n, &k);
  for (i = 1; i <= n; i++) scanf("%d", &a[i]);
  kk = n / k;
  l = 1;
  for (j = 0; j < kk; j++)
    for (i = 1; i <= k; i++, l++) {
      if (a[l] == 1) c[i]++;
    }
  for (i = 1; i <= k; i++)
    if (kk - c[i] > c[i])
      ans += c[i];
    else
      ans += kk - c[i];
  printf("%d\n", ans);
}
