#include <bits/stdc++.h>
template <typename T>
std::istream& operator>>(std::istream& in, std::vector<T>& arr) {
  for (T& i : arr) {
    in >> i;
  }
  return in;
}
template <typename T>
std::ostream& operator<<(std::ostream& out, std::vector<std::vector<T>>& arr) {
  for (std::vector<T>& i : arr) {
    out << i;
  }
  out << std::endl;
  return out;
}
template <typename T>
std::ostream& operator<<(std::ostream& out, std::vector<T>& arr) {
  for (T i : arr) {
    out << i << ' ';
  }
  out << std::endl;
  return out;
}
using namespace std;
int main() {
  int n, k;
  cin >> n >> k;
  std::vector<int> arr(n);
  cin >> arr;
  std::vector<bool> need_count(n, true);
  int min_elem = -1, min_sum = INT_MAX;
  for (int i = 0; i < n; i++) {
    if (!need_count[i]) continue;
    int sum = 0;
    bool f = true;
    for (int j = i; f || i != j; j += k) {
      f = false;
      sum += arr[j];
      need_count[j] = false;
      if (j + k >= n) {
        j = j - n;
      }
    }
    if (sum < min_sum) {
      min_sum = sum;
      min_elem = i;
    }
  }
  cout << (min_elem + 1);
}
