#include <bits/stdc++.h>
using namespace std;
int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  ;
  long long n, k, i, j, p, ans = 100000000, cnt, a, pos, div;
  vector<pair<long long, long long>> v;
  cin >> n >> k;
  div = n / k;
  for (i = 0; i < n; i++) {
    cin >> a;
    v.push_back({a, i + 1});
  }
  if (k == 1) {
    pos = 1;
  } else if (k == n) {
    sort(v.begin(), v.end());
    pos = v[0].second;
  } else {
    for (i = 0; i < k; i++) {
      cnt = 0;
      for (j = 1, p = i; j <= div; j++, p += k) {
        if (p >= n) {
          p = p - n;
        }
        cnt += v[p].first;
      }
      if (n % k != 0) {
        cnt += v[p + k].first;
      }
      if (cnt < ans) {
        ans = cnt;
        pos = v[i].second;
      }
    }
  }
  cout << pos << endl;
  return 0;
}
