#include <bits/stdc++.h>
using namespace std;
int main() {
  cin.tie(0);
  std::ios::sync_with_stdio(false);
  int n, k;
  cin >> n >> k;
  int arr[n + 1];
  for (int i = 1; i <= n; i++) {
    cin >> arr[i];
  }
  int a = n / k;
  long minim = 1000000000;
  int s = 0;
  for (int i = 1; i <= k; i++) {
    long long sum = 0;
    int count = 0;
    for (int j = i; count != a; j += k) {
      sum += arr[j];
      count++;
    }
    if (sum < minim) {
      minim = sum;
      s = i;
    }
  }
  cout << s;
}
