One day shooshuns found a sequence of *n* integers, written on a blackboard. The shooshuns can perform one operation with it, the operation consists of two steps:
 1.  Find the number that goes *k*-th in the current sequence and add the same number to the end of the sequence; 1.  Delete the first number of the current sequence. 
The shooshuns wonder after how many operations all numbers on the board will be the same and whether all numbers will ever be the same.
The first line contains two space-separated integers *n* and *k* (1 ≤ *k* ≤ *n* ≤ 10<sup class="upper-index">5</sup>).

The second line contains *n* space-separated integers: *a*<sub class="lower-index">1</sub>, *a*<sub class="lower-index">2</sub>, ..., *a*<sub class="lower-index">*n*</sub> (1 ≤ *a*<sub class="lower-index">*i*</sub> ≤ 10<sup class="upper-index">5</sup>) — the sequence that the shooshuns found.
class Node:
  def __init__(self,data):
    self.data=data
    self.next=None

class LinkedList:
	def __init__(self):
		self.head=Node(1)

	def insert(self,data):
		node = Node(data)
		if(self.head==None):
			self.head=node
		else:
			nn=self.head.next
			self.head.next=node
			node.next=nn

	def ins(self,data):
		temp=self.head
		node=Node(data)
		while(temp.next!=None):
			temp=temp.next
		temp.next=node

	def print(self):
		print(self.head.data)

	def printlist(self):
		temp=self.head
		while(temp!=None):
			print(temp.data)
			temp=temp.next

	def move(self):
		self.head=self.head.next

if __name__=='__main__':
	n,k=map(int,input().split(" "))
	l=list(map(int,input().split(" ")))
	val=l[k-1]
	c=0
	for i in range(k,n):
		if(l[k]!=val):
			c=-1
			break
	if(c==-1):
		print(c)
	else:
		j=k-1
		while(j>=0):
			if(l[j]!=val):
				break
			else:
				j=j-1
		print(j+1)

