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.
#include<bits/stdc++.h>
using namespace std;
#define endl '\n'
#define sp " "
//const double pi = acos(-1);
long long mod = 1e9 + 7;
//int dp[100000007];
//long long f[100001];
/*long long pow(long long a, long long b, long long MOD)
{long long x=1,y=a;
 while(b > 0){if(b%2 == 1){x=(x*y);if(x>MOD) x%=MOD;}y = (y*y);if(y>MOD) y%=MOD;b /= 2;}return x;}
long long InverseEuler(long long n, long long MOD)
{return pow(n,MOD-2,MOD);}
*/
long long multicases(bool q)
{
    if(q  == 0)
        return 1;
    else
    {long long x;cin >> x;return x;}
}
void test_case()
   {
       int n,ans = 0,k;cin >> n >> k;
       set<int>l1;
       vector<int>l(n);for(int  &e : l)
       {cin >> e;l1.insert(e);}
       int sz = l1.size();
       int k1 = l[k - 1];
       for(int i = k ; i < l.size();i++)
       {
           if(l[i] != k1)
           {cout << -1;return;}
       }
       while(sz != 1)
       {
           l.push_back(k1);
           if(l.at(0) != k1)
            sz--;
           l.erase(l.begin());
           ans++;
       }
       cout << ans;

   }
int main()
{
#ifndef ONLINE_JUDGE
    std::ios_base::sync_with_stdio(0);
    std::cin.tie(nullptr),std::cout.tie(nullptr);
#endif

    long long t = multicases(0);
    //cin.ignore();
    while(t--)
    {test_case();}
    return 0;
}
