import std.functional,
       std.algorithm,
       std.container,
       std.typetuple,
       std.typecons,
       std.bigint,
       std.string,
       std.traits,
       std.array,
       std.range,
       std.stdio,
       std.conv;

bool chmin(t)(ref t a, t b) {
  if (b < a) {
    a = b;
    return true;
  } else {
    return false;
  }
}

int repL(int[] A, int K, int c = 0) {
  if (A.length == 1 && A[0] == 1) {
    return 0;
  }

  if (A.length <= K) {
    return c + 1;
  } else {
    return repL(A[0..$-K+1], K, c + 1);
  }
}

int repR(int[] A, int K, int c = 0) {
  if (A.length == 1 && A[0] == 1) {
    return 0;
  }

  if (A.length <= K) {
    return c + 1;
  } else {
    return repR(A[K-1..$], K, c + 1);
  }
}

void main() {
  int[] NK = readln.chomp.split.to!(int[]);
  int N = NK[0],
      K = NK[1];
  int[] A = readln.chomp.split.to!(int[]);

  size_t idx;
  foreach (i, a; A) {
    if (a == 1) {
      idx = i;
      break;
    }
  }

  int min = int.max;

  foreach (t; idx-K..idx) {
    auto ret = repL(A[0..t], K) + repR(A[t+K..$], K) + 1;
    chmin(min, ret);
  }

  int t = repL(A[0..idx+1], K) + repR(A[idx..$], K);
  chmin(min, t);

  writeln(min);
}

