public void solve() throws IOException {
    int n = nextInt();
    int k = nextInt();
    int[] pow = new int[n];
    for (int x = 0; x < n; x++)
      pow[x] = nextInt();

    int minpow = Integer.MAX_VALUE;
    int minindex = -1;
    for (int x = 0; x < k; x++) {
      int total = 0;
      for (int y = 0; y < n / k; y++) {
        int index = (x + y * k) % n;
        total += pow[index];
      }
      if (total < minpow) {
        minpow = total;
        minindex = x;
      }
      // System.out.println(x + " " + total);
    }
    System.out.println(minindex + 1);

  }