#include <bits/stdc++.h>
using namespace std;
int k[100005], f[100005];
int main() {
  int n, m, ans = INT_MAX, cnt;
  cin >> n >> m;
  for (int i = 0; i < n; i++) {
    cin >> k[i];
    f[i % m] += k[i];
  }
  for (int i = 0; i < m; i++)
    if (ans > f[i]) {
      ans = f[i];
      cnt = i + 1;
    }
  cout << cnt << endl;
  return 0;
}
