#include <bits/stdc++.h>
using namespace std;
int main() {
  int n, k;
  cin >> n >> k;
  int a[200];
  for (int i = 0; i < n; i++) {
    cin >> a[i];
  }
  int res = 0;
  for (int i = 0; i < k; i++) {
    bool diff = false;
    int c[2] = {0, 0};
    for (int j = 0; j < n / k - 1; j++) {
      if (j == 0) c[a[i] - 1]++;
      c[a[k * (j + 1) + i] - 1]++;
      if (a[k * j + i] != a[k * (j + 1) + i]) {
        diff = true;
      }
    }
    if (diff) res += min(c[0], c[1]);
  }
  cout << res << endl;
}
