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