#include <bits/stdc++.h>
using namespace std;
int n, k, a[100001];
int Try();
int Min(int, int);
int main() {
  int min = 2000000000;
  cin >> n >> k;
  for (int i = 1; i <= n; i++) cin >> a[i];
  int kk, vt;
  long long t;
  for (int i = 1; i <= k; i++) {
    t = 0;
    for (int j = i; j < i + n; j += k) {
      kk = j;
      if (kk > n) kk -= n;
      t += a[kk];
    }
    if (t < min) {
      min = t;
      vt = i;
    }
  }
  cout << vt;
}
