#include <bits/stdc++.h>
using namespace std;
int n, k;
int arr[110];
int rite[110];
int con;
int cal() {
  int ans = 0;
  int r = n / k;
  for (int i = 1; i <= k; i++) {
    int sum = 0;
    int a = i;
    for (int j = 1; j <= r; j++) {
      if (arr[a] == 1) sum++;
      a += k;
    }
    ans = ans + min(sum, r - sum);
  }
  return ans;
}
int main() {
  cin >> n >> k;
  for (int i = 1; i <= n; i++) {
    cin >> arr[i];
  }
  cout << cal() << endl;
  return 0;
}
