Lottery 2

No attempts yetTime limit1sMemory limit128 MB

Problem

The Byteotian Lotto company runs number games and cash lotteries. Its most popular product is a lottery called Number Draw. Bajtazar decided to try his luck with it.

A Number Draw coupon has nn boxes. In each box you can mark one of the numbers 11 through kk. The picture below shows a coupon filled in for n=10n = 10 and k=3k = 3.

The draw uses a drawing machine that holds nn balls of every type 11 through kk, so nknk balls in total. The top of the machine has nn evenly spaced holes, each narrower than a ball. Partway through the draw a pneumatic mechanism starts up and sucks exactly one ball onto each hole. Reading the numbers on those balls from left to right gives a sequence of nn numbers, and that sequence is the result of the draw. Everyone whose coupon carries exactly that sequence shares the main prize, a million bytalars. The picture below shows a draw result that would win the main prize for the coupon above.

Bajtazar bought a coupon and marked nn numbers on it. Before he handed it in at the outlet, the press reported that the Number Draw is not entirely fair. Balls of the same type, meaning balls carrying the same number, repel each other, so during a draw they never stick to two adjacent holes. The arrangement in the picture above, for instance, cannot happen.

Once he heard this, Bajtazar decided to change some of the nn numbers he marked so that no two adjacent numbers are equal. He does not want to push his luck, so he wants to change as few numbers as possible. A box he corrects still has to carry a number between 11 and kk. Work out how many numbers Bajtazar has to change.

Input

The first line contains two integers nn and kk (2n,k5000002 \le n, k \le 500\,000).

The second line contains nn integers between 11 and kk, separated by single spaces. At least one pair of adjacent numbers in this sequence is equal.

Output

Print the smallest number of entries that have to be changed so that no two equal numbers stand next to each other.