#include <bits/stdc++.h>
using namespace std;
const int inf = 2e9;
const long long INF = 4e17;
const int mod = 1e9 + 7;
const double eps = 1e-9;
int n, k, arr[105];
vector<int> v[105];
int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  cin >> n >> k;
  for (int i = 0; i < n; i++) cin >> arr[i];
  for (int i = 0; i < n; i += k) {
    for (int j = i; j < i + k; j++) v[i / k].push_back(arr[j]);
  }
  int ans = 0;
  for (int j = 0; j < k; j++) {
    int one = 0, two = 0;
    for (int i = 0; i < n / k; i++) {
      one += (v[i][j] == 1);
      two += (v[i][j] == 2);
    }
    ans += min(one, two);
  }
  cout << ans;
  return 0;
}
