#include <bits/stdc++.h>
using namespace std;
int32_t main() {
  ios::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  ;
  long long n, k;
  cin >> n >> k;
  long long arr[n];
  for (long long i = 0; i < n; i++) cin >> arr[i];
  long long s = 0;
  for (long long i = 0; i < k; i++) {
    long long o = 0, t = 0;
    for (long long j = i; j < n; j = j + k) {
      if (arr[j] == 1)
        o++;
      else
        t++;
    }
    s = s + n / k - max(o, t);
  }
  cout << s;
}
