#include <bits/stdc++.h>
using namespace std;
double pi = 3.14159265359;
int n;
int k;
int a;
int b[100009];
int main() {
  cin >> n >> k;
  for (int i = 0; i < n; i++) {
    cin >> a;
    b[i % k] += a;
  }
  int m, ind;
  bool c = true;
  for (int i = k - 1; i >= 0; i--) {
    if (c || m >= b[i]) {
      c = false;
      m = b[i];
      ind = i;
    }
  }
  cout << ind + 1;
  return 0;
}
