#include <bits/stdc++.h>
using namespace std;
int Ans;
int A[105];
int main() {
  int N, K;
  cin >> N >> K;
  for (int i = 0; i < N; i++) {
    cin >> A[i];
  }
  int rep = N / K;
  for (int i = 0; i < K; i++) {
    int one = 0;
    int two = 0;
    for (int j = 0; j < rep; j++) {
      if (A[i + j * K] == 1)
        one++;
      else
        two++;
    }
    Ans += min(one, two);
  }
  cout << Ans << endl;
  return 0;
}
