#include <bits/stdc++.h>
using namespace std;
int book[110][3], s[110], maxn[110], maxi[110];
int main() {
  int n, k, t, ans, temp, l;
  scanf("%d%d", &n, &k);
  for (int i = 1; i <= n; i++) {
    scanf("%d", &s[i]);
  }
  t = 0;
  memset(maxn, 0, sizeof(maxn));
  memset(maxi, 0, sizeof(maxi));
  l = n / k;
  while (t < n) {
    for (int i = 1; i <= k; i++) {
      book[i][s[i + t]]++;
      if (book[i][s[i + t]] > maxn[i]) {
        maxn[i] = book[i][s[i + t]];
        maxi[i] = s[i + t];
      }
    }
    t += k;
  }
  t = 0;
  ans = 0;
  while (t < n) {
    for (int i = 1; i <= k; i++) {
      if (s[i + t] != maxi[i]) ans++;
    }
    t += k;
  }
  cout << ans << endl;
}
