#include <bits/stdc++.h>
using namespace std;
int main() {
  int n, k, arr[100], out = 0, ans = 0;
  cin >> n >> k;
  for (int i = 0; i < n; i++) {
    cin >> arr[i];
  }
  for (int i = 0; i < k; i++) {
    for (int j = 1; j < n / k; j++) {
      if (arr[i] != arr[i + (k * j)]) {
        out = 0;
        for (int a = i; a <= (n - k + i); a = a + k) {
          if (arr[a] == 1) out++;
        }
        if (out > (n / k) / 2)
          ans += (n / k) - out;
        else
          ans += out;
        break;
      }
    }
  }
  cout << ans;
}
