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