Олимпиадный тренинг

Задача 38629. minimization


Задача

Темы: Вывод формулы
There is a sequence of length N: A1, A2, ..., AN. Initially, this sequence is a permutation of 1, 2, ..., N. In this sequence, Alice can perform the following operation:
1) select K consecutive elements in sequence;
2) then replace the value of each selected element with the minimum value among the selected elements.
Alice wants to equalize all the elements in this sequence by repeating the above operation a number of times.
Find the minimum number of necessary operations.
It can be proved that, under the constraints of this problem, this goal is always achievable.

Input
The first line specifies two integers N and K (2<=K<=N<=100000). The second line specifies a sequence of integers A1, A2, ..., AN - permutation of numbers from 1 to N (each number in the sequence is different, 1<=Ai <=N).

Imprint
Print the minimum number of required operations.
 

 

Examples
# Input Output
1 4 3
2 3 1 4
2
2 3 3
1 2 3
1
3 8 3
7 3 1 8 4 6 2 5
4