N, K = map(int, raw_input().split()) s = raw_input() cnt = 0 if s[K-1] == ")": s = s[:K] for i in reversed(xrange(len(s))): if s[i] == ")": cnt += 1 if s[i] == "(": cnt -= 1 if cnt == 0: print i+1 else: s = s[K-1:] for i in xrange(len(s)): if s[i] == "(": cnt += 1 if s[i] == ")": cnt -= 1 if cnt == 0: print i + K