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