#include <bits/stdc++.h>
using namespace std;
int a[102], ans;
int main() {
  int n, k;
  scanf("%d%d", &n, &k);
  for (int i = 0; i < n; i++) scanf("%d", a + i);
  for (int i = 0; i < k; i++) {
    int cnt = 0;
    for (int j = i + k; j < n; j += k) cnt += a[i] != a[j];
    ans += min(cnt, n / k - cnt);
  }
  printf("%d", ans);
  return 0;
}
