#include <bits/stdc++.h>
using namespace std;
int MOD = 1000003;
int tmp = 1e9, ans;
const int N = 1e5 + 5;
int n, k, i;
int ar[N];
map<int, int> mp;
int main() {
  scanf("%d%d", &n, &k);
  for (i = 0; i < n; i++) {
    scanf("%d", &ar[i]);
  }
  for (int j = 0; j < k; j++) {
    for (i = j; i < n; i += k) {
      mp[j] += ar[i];
    }
  }
  for (auto it : mp) {
    if (tmp > it.second) {
      tmp = it.second;
      ans = it.first;
    }
  }
  printf("%d\n", ans + 1);
  return 0;
}
