n,k = map(int, input().split()) s = list(input()) #print(s) count = 1 #k番目の文字を+1として同じ文字なら+1,違う文字なら-1する if s[k-1] == "(": i = k while i <= n: if s[i] == "(": count += 1 else: count -= 1 if count == 0: print(i + 1) break else: i += 1 else: i = k - 2 while i >= 0: if s[i] == ")": count += 1 else: count -= 1 if count == 0: print(i + 1) break else: i -= 1