#include <bits/stdc++.h>
using namespace std;
int main() {
  int a, b;
  cin >> a >> b;
  vector<int> numbers;
  int sum = 0;
  long long min = 10000000000;
  int index = -1;
  for (int g = 0; g < a; g++) {
    int c;
    cin >> c;
    numbers.push_back(c);
  }
  for (int g = 0; g <= b - 1; g++) {
    for (int y = g; y <= numbers.size() - 1; y += b) {
      sum += numbers[y];
    }
    if (sum < min) {
      index = g;
      min = sum;
    }
    sum = 0;
  }
  cout << index + 1;
  return 0;
}
