Annihilator Gun
In the Link-Cut system, there are planets, each with its own type. The type of a planet is an integer ranging from to . You are given an array of integers representing the types of each planet. Your goal is to make all planets of the same type or determine that it is impossible.
To achieve this, Lucy has constructed an annihilator gun for you, which can change the types of each planets to any other types (from to ) that are not equal to their previous types in one use. The new types of planets do not necessarily have to be distinct.
More formally, in one use of the gun, you can create an array of integers from to such that for all , and then assign each element of the array a new value .
Since using the annihilator gun is quite resource-intensive, and you need to save resources for capturing the evil Chmyaaax, you need to achieve the goal in the minimum number of uses of the gun. Your task is to determine this number or to determine that it is impossible to make all planets of one type.
Input
The first line contains two integers and — the number of planets and the number of possible types for each planet.
The second line contains integers — the types of the planets.
Output
In a single line, you need to output the minimum number of uses of the annihilator gun required to make all planets of the same type or if it is impossible.
Examples
Note
In the first example, you can do the only use of the gun, changing the types of both planets to . Since their initial types are different, the answer cannot be .
In the second example, it can be shown that it is not possible to make both planets of the same type.
In the third example, all the planets have the same type initially, thus you do not need to do anything.
In the fourth example, you can use the gun two times:
It can be shown that the condition cannot be satisfied in one use of the gun.
Scoring
( points): ;
( points): ;
( points): ;
( points): ;
( points): ;
( points): no additional constraints.