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.
'''
 R E X

 Date - 08th June 2021


 @author:
 CodeForces -> kunalverma19
 CodeChef   -> kunalverma_19
 AtCoder    -> TLKunalVermaRX
'''
import math
import re
import sys
from itertools import permutations
from collections import Counter
MOD  = 1000000007
inp  = lambda : map(int,input().split(' '))
ninp = lambda : int(input())
# sys.stdin=open("input.txt","r")
n,k=inp();
a=list(inp());
if (a.count(a[k-1])<=1):
	print(-1)
else:
	cnt=0;
	j=k;
	for i in range(len(a)):
		a.append(a[k-1]);
		a.remove(a[0]);
		cnt+=1;
		if (a==[a[j-1]]*n):
			break;
	print(cnt);







