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