#include <bits/stdc++.h>
using namespace std;
int main() {
  int n, k;
  cin >> n >> k;
  int arr[n];
  for (long long i = (1); i < (n + 1); i++) cin >> arr[i];
  int val = INT_MAX;
  for (int i = k + 1; i <= n; i++) {
    arr[i] += arr[i - k];
  }
  int ans = n;
  for (int i = n; i > n - k; i--) {
    if (arr[i] <= val) {
      val = arr[i];
      ans = i;
    }
  }
  ans %= k;
  if (ans == 0) {
    ans = k;
  }
  cout << ans << "\n";
  return 0;
}
