#include <bits/stdc++.h>
using namespace std;
int a[100005];
int main() {
  int n, k;
  int i, j, l;
  scanf("%d %d", &n, &k);
  for (i = 1; i <= n; i++) scanf("%d", &a[i]);
  int x = n / k;
  int sum = 0;
  for (i = 1; i <= k; i++) {
    int m = 0;
    for (j = i; j <= n; j += k) {
      int count = 0;
      for (l = j; l <= n; l += k) {
        if (a[j] == a[l]) count++;
        if (count > m) m = count;
      }
    }
    sum += (x - m);
  }
  printf("%d\n", sum);
  return 0;
}
