#include <bits/stdc++.h>
using namespace std;
int a[101000];
struct stu {
  int sum;
  int num;
} node[101000];
int cmp(stu b, stu d) {
  if (b.sum != d.sum) return b.sum < d.sum;
  return b.num < d.num;
}
int main() {
  int i, j, k, n, m, sum, t;
  while (scanf("%d%d", &n, &k) == 2) {
    for (i = 1; i <= n; i++) scanf("%d", &a[i]);
    for (i = 1; i <= k; i++) {
      node[i].sum = 0;
      node[i].num = i;
      j = i + k;
      if (j > n) j = j - n;
      node[i].sum += a[i];
      while (j != i) {
        node[i].sum += a[j];
        j = j + k;
        if (j > n) j = j - n;
      }
    }
    sort(node + 1, node + 1 + k, cmp);
    printf("%d\n", node[1].num);
  }
  return 0;
}
