#include <bits/stdc++.h>
using namespace std;
signed main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  long long n, k, i, j, mn = INT_MAX, c, sum = 0;
  cin >> n >> k;
  long long t = n / k;
  long long a[n];
  for (long long i = (long long)0; i < (long long)n; i++) cin >> a[i];
  for (i = 0; i < k; i++) {
    j = 0;
    t = n / k;
    sum = 0;
    while (t--) {
      sum += a[i + j * k];
      j++;
    }
    if (sum < mn) {
      mn = sum;
      c = i;
    }
  }
  cout << c + 1;
}
