#include <bits/stdc++.h>
using namespace std;
int MX = 0;
int main() {
  int n, k;
  cin >> n >> k;
  int a[101];
  for (int i = 0; i < n; i++) cin >> a[i];
  for (int i = 0; i < k; i++) {
    int b = 0, ik = 0;
    for (int j = i; j < n; j += k) {
      if (a[j] == 1)
        b++;
      else
        ik++;
    }
    MX += min(ik, b);
  }
  cout << MX;
}
