#include <bits/stdc++.h>
using namespace std;
const int MAXN = 1e5 + 10;
const int pN = 1e6;
const int INF = 0x3f3f3f3f;
const int MOD = 1e9 + 7;
void add(long long &x, long long y) {
  x += y;
  x %= MOD;
}
bool vis[MAXN];
int a[MAXN];
int main() {
  int n, k;
  cin >> n >> k;
  for (int i = 0; i < n; i++) cin >> a[i];
  int ans = INF;
  int id;
  for (int i = 0; i < n; i++) {
    if (vis[i]) continue;
    int sum = 0;
    for (int j = i;; j = (j + k) % n) {
      if (vis[j]) break;
      vis[j] = true;
      sum += a[j];
    }
    if (sum < ans) {
      id = i;
      ans = sum;
    }
  }
  cout << id + 1 << endl;
  return 0;
}
