eolymp
bolt
Try our new interface for solving problems
Problems

First element occurring k times in an array

First element occurring k times in an array

Given an array of n integers. Find the first element that occurs k number of times. If no element occurs k times, print -1.

Input

The first line contains numbers n and k (n, k105). Second line contains n integers, each no more than 109 by absolute value.

Output

Print the first element that occurs k times. If no element occurs k times, print -1.

Time limit 1 second
Memory limit 128 MiB
Input example #1
7 2
1 7 4 3 4 8 7
Output example #1
7
Input example #2
6 1
4 1 6 1 6 4
Output example #2
-1
Author Michael Medvediev