#include <bits/stdc++.h>
using namespace std;
int n, k, i, j, l, v[105], s = 0, f[105][105], t1, t2;
int main() {
  cin >> n >> k;
  for (i = 1; i <= n; i++) cin >> v[i];
  i = 1;
  j = 1;
  while (i <= n) {
    l = 1;
    while (l <= k) {
      f[j][l] = v[i];
      l++;
      i++;
    }
    j++;
  }
  for (j = 1; j <= k; j++) {
    t1 = 0;
    t2 = 0;
    for (i = 1; i <= n / k; i++)
      if (f[i][j] == 1)
        t1++;
      else
        t2++;
    if (n / k > max(t1, t2)) s += min(t1, t2);
  }
  cout << s;
  return 0;
}
