def checker(s, x, f): i = 1 if f else -1 chk = ")" if f else "(" a = [x] while (True): x += i if x < 1 or x > len(s): break if s[x - 1] == chk: if len(a) == 1: return x else: a.pop() else: a.append(x) return -1 n, k = map(int, input().split()) s = input() print(checker(s, k, s[k - 1] == "("))