import sys input = sys.stdin.readline def main(): N, K = map(int, input().split()) S = [] for i, s in enumerate(input().rstrip()): if s == '(': S.append(i) else: a = S.pop() if 1+a == K or 1+i == K: print(a+i+2-K) return if __name__ == '__main__': main()