#include <bits/stdc++.h>
using namespace std;
long long power(long long x, long long y) {
  if (y == 0)
    return 1;
  else {
    long long result = power(x, y / 2) % 1000000007;
    if (y % 2 == 0)
      return (result % 1000000007 * result % 1000000007) % 1000000007;
    else
      return (result % 1000000007 * result % 1000000007 * x % 1000000007) %
             1000000007;
  }
}
long long gcd(long long a, long long b) {
  if (b == 0)
    return a;
  else
    return gcd(b, a % b);
}
long long lcm(long long a, long long b) { return (a / gcd(a, b)) * b; }
void solve() {
  long long n, k;
  cin >> n >> k;
  vector<long long> v(n);
  for (long long i = 0; i < n; i++) {
    cin >> v[i];
  }
  long long start = -1;
  long long sum = 0;
  long long div = n / k;
  long long minsum = INT_MAX;
  for (long long i = 0; i < k; i++) {
    sum = 0;
    for (long long j = i; j < n; j = j + k) {
      sum = sum + v[j];
    }
    if (sum < minsum) {
      minsum = sum;
      start = i + 1;
    }
  }
  cout << start;
}
int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  long long t;
  t = 1;
  while (t--) {
    solve();
  }
  return 0;
}
