Practice on Toph

Participate in exhilarating programming contests, solve unique algorithm and data structure challenges and be a part of an awesome community.

Aloyna and Can Buying

By prodip_bsmrstu · Limits 1s, 512 MB

Aloyna is a can lover girl and whenever she goes to a shop, she must buy a can to drink. This time she goes to a shop to buy a can. There are $n$ cans in the shop of $k$ types. The types are numbered from $1$ to $k$.

She will buy a specific type of can if the quantity of this type of can is the maximum in the shop. Can you find which type of can Aloyna will buy?

Input

In the first line, there will be 2 integers $n$ ($1 \le n \le 1000$) and $k$ ($1 \le k \le 100$).

In the next line, there will be n integers, $a_1$, $a_2$, $a_3$, …, $a_n$ ($1 \le a_i \le k$), the types of each can in the shop.

Output

Print a number, the type number of the can which Aloyna will buy from the shop. If there are multiple answers then choose the can whose type number is minimum.

Samples

InputOutput
6 3
1 2 2 2 1 3
2

There are 6 cans of 3 types and type #1’s quantity is 2, type #2’s quantity is 3 and type #3’s quantiy is 1. Since type #2’s quantity is the maximum, so the answer is 2.

InputOutput
3 3
1 2 3
1

Since every type’s quantity is the same, so the answer is the can whose type number is minimum which is 1 in this case.


Discussion

Statistics


87% Solution Ratio

iammarajulEarliest, 5M ago

iammarajulFastest, 0.0s

RubiathLightest, 0 B

razwan_islamShortest, 125B

Submit

Login to submit

Editorial

Just count the occurrences of every type and print the max occurring one.