#include <bits/stdc++.h>
using namespace std;
const int maxn = 100 + 10;
int k, n, s[maxn], cnt[3][maxn];
int main() {
  while (scanf("%d%d", &n, &k) != EOF) {
    memset(cnt, 0, sizeof cnt);
    for (int i = 1; i <= n; i++) scanf("%d", &s[i]);
    for (int i = 1; i <= k; i++)
      for (int j = 0, len = n / k; j < len; j++) ++cnt[s[i + j * k]][i];
    int ans = 0;
    for (int i = 1; i <= k; i++) ans += min(cnt[1][i], cnt[2][i]);
    printf("%d\n", ans);
  }
  return 0;
}
