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.
"""
Brandt Smith, Peter Haddad and Lemuel Gorion

Codeforces.com

Problem 222A
"""

one, two = input().split(' ')
one = int(one)
two = int(two) - 1  # Numbers are given with index starting at 1 instead of 0

board = input().split(' ')
s = set(board[two:]) # If theres anything past k or 'two' thats different than it
                     # then its impossible

if len(s) > 1:
    print(-1)
    quit()

else:
    if two >= 1: # If the k value is after the first element we need to find 
        while(True):
            x = two - 1
            if board[two] != board[x]: # Where the value at k doesnt equal a value in the list
                print(x + 1) # Up to that element we need to change, including that element so +1
                break
            x -= 1

    elif two == 0: # If the set only contains one element and the k value is the first index nothing needs to be done
        print(0)
        
            
    
    


    
