#include <bits/stdc++.h>
using namespace std;
const int M = 1e5 + 5;
int n, k, t[M];
int main() {
  cin >> n >> k;
  for (int i = 1; i <= n; i++) cin >> t[i];
  int g = 0;
  for (int i = 1; i <= n; i++) {
    if (t[i] != t[k]) g = i;
  }
  cout << (g > k ? -1 : g);
}
