#include <bits/stdc++.h>
using namespace std;
int main() {
  int A[101];
  int B[101];
  int n, k;
  cin >> n >> k;
  for (int i = 0; i < n; i++) cin >> A[i];
  int t = n / k;
  for (int i = 0; i < k; i++) {
    int max1 = 0;
    int max2 = 0;
    for (int j = 0; j < t; j++)
      if (A[i + j * k] == 1)
        max1++;
      else
        max2++;
    if (max2 > max1)
      B[i] = 2;
    else
      B[i] = 1;
  }
  int d = 0;
  for (int i = 0; i < t; i++) {
    for (int j = 0; j < k; j++)
      if (A[i * k + j] != B[j]) d++;
  }
  cout << d;
  return 0;
}
