#include <bits/stdc++.h>
#pragma comment(linker, "/STACK:33554432")
using namespace std;
int n, k;
int a[1 << 7];
int main() {
  cin >> n >> k;
  for (int i = 0; i < n; ++i) cin >> a[i];
  int res = 0;
  for (int i = 0; i < k; ++i) {
    int b = 0, c = 0;
    for (int j = 0; j < n / k; ++j)
      if (a[j * k + i] == 1)
        b++;
      else
        c++;
    res += min(c, b);
  }
  cout << res << endl;
  return 0;
}
