n, k = map(int, input().split()) s = input() num = [0]*n num[0] = 1 for i in range(1,n): if s[i] =="(": if s[i-1] ==")": num[i] = num[i-1] else: num[i] = num[i-1] + 1 if s[i] ==")": if s[i-1] =="(": num[i] = num[i-1] else: num[i] = num[i-1] - 1 if s[k-1] == "(": for i in range(k,n): if num[i] == num[k-1]: print(i+1) exit() if s[k-1] == ")": for i in range(0,k-1)[::-1]: if num[i] == num[k-1]: print(i+1) exit()