Problem:
Score : 300 points

Problem Statement

There is a sequence of length N: A_1, A_2, ..., A_N. Initially, this sequence is a permutation of 1, 2, ..., N.

On this sequence, Snuke can perform the following operation:

Choose K consecutive elements in the sequence. Then, replace the value of each chosen element with the minimum value among the chosen elements.

Snuke would like to make all the elements in this sequence equal by repeating the operation above some number of times.
Find the minimum number of operations required.
It can be proved that, Under the constraints of this problem, this objective is always achievable.

Constraints

2 \leq K \leq N \leq 100000

A_1, A_2, ..., A_N is a permutation of 1, 2, ..., N.

Input

Input is given from Standard Input in the following format:

N K
A_1 A_2 ... A_N

Output

Print the minimum number of operations required.

Sample Input 1

4 3
2 3 1 4

Sample Output 1

2

One optimal strategy is as follows:

In the first operation, choose the first, second and third elements. The sequence A becomes 1, 1, 1, 4.

In the second operation, choose the second, third and fourth elements. The sequence A becomes 1, 1, 1, 1.

Sample Input 2

3 3
1 2 3

Sample Output 2

1

Sample Input 3

8 3
7 3 1 8 4 6 2 5

Sample Output 3

4

Solution in JavaScript (node.js v5.12) (judge verdict: Wrong Answer)

function myin(){return require("fs").readFileSync("/dev/stdin", "utf8").trim();}
function myout(t){console.log(t);}//standard output
function myerr(t){console.error(t);}//standard error
//[no]param
//0:何もしない  1:数値へ変換  2:半角SPで分割  3:改行で分割  4:半角SPで分割し、数値配列へ
//5:改行で分割し、数値配列へ  6:1文字に分割  7:1文字に分割し、数値配列へ
function myconv(i,no){switch(no){case 0:return i;case 1:return parseInt(i);case 2:return i.split(" ");case 3:return i.split("\n");case 4:return i.split(" ").map((a)=>Number(a));case 5:return i.split("\n").map((a)=>Number(a));case 6:return i.split("");case 7:return i.split("").map((a)=>Number(a));}}
function Main(input) {
  input = myconv(input,3);
  var N = myconv(input[0],4)[0];
  var K = myconv(input[0],4)[1];
  var list = myconv(input[1],4);
  if(N == K){
     myout(1);
    return;
  }else if(K == 1){
     myout(N);      
    return;
	}
  //1の位置を特定し、左側と右側で何回K要素をとる必要があるか
  var index1 = 0;
  for(var i = 0; i < N; i++){
    if(list[i] == 1){
       index1 = i+1;
    }
  }
  var output = 0;
  var mae = 0;
  var ato = 0;
  if(index1 <= K){
    if(index1 == 1){
       mae = 0;
    }else{
      mae = 1; 
    }
  }else{
    mae = 1;
    var tmpIndex1 = index1 - K; 
    mae += Math.ceil(tmpIndex1 / (K-1));
  }
  var ato = 0;
  if(N - index1 + 1 <= K){
    if(index1 == N){
       ato = 0;
    }else{
     ato = 1;
    }
  }else{
    ato = 1;
    var tmpIndex1 = (N - index1 + 1) - K;
    ato += Math.ceil(tmpIndex1 / (K-1));
  }
  myerr(mae);
  myerr(ato);
  myout(mae + ato);
}
Main(myin());