import math import numpy as np import queue import sys input = sys.stdin.readline # sys.setrecursionlimit(25000) n, k = list(map(int, input().split(' '))) s = input() s_i = [i for i in range(1, n + 1)] stack = queue.LifoQueue() stack_i = queue.LifoQueue() stack.put(s[0]) stack_i.put(s_i[0]) i = 1 result = -1 while(i < n): val = s[i] val_i = s_i[i] top = stack.get() if top != val: temp = stack_i.get() if temp == k: result = val_i break elif val_i == k: result = temp break else: stack.put(top) stack.put(val) stack_i.put(val_i) i += 1 print(result)