#include <bits/stdc++.h>
using namespace std;
long long n, m, i, j, k, t, ans, dp[100001], p;
int main() {
  ios_base::sync_with_stdio(0);
  static const size_t npos = -1;
  cin >> n >> k;
  long long a[n + 1];
  for (i = 1; i <= n; i++) cin >> a[i];
  t = n / k;
  ans = 1000000007;
  m = 1000000007;
  map<long long, long long> mp;
  for (i = 1; i <= n; i++) {
    mp[i % k] += a[i];
  }
  for (i = 1; i <= n; i++) {
    m = (((m) < (mp[i % k])) ? (m) : (mp[i % k]));
  }
  for (i = 1; i <= n; i++) {
    if (mp[i % k] == m) {
      cout << i << endl;
      return 0;
    }
  }
  return 0;
}
