using System; using System.Linq; using System.Collections.Generic; namespace Algorithm { class Program { static void Main(string[] args) { var l = Console.ReadLine().Split().Select(int.Parse).ToArray(); int N = l[0], K = l[1]; var S = Console.ReadLine(); var stack = new Stack(); var right = S[K - 1] == '(' ? true : false; var ans = 0; var count = 0; for (var i = 0; i < S.Length; i++) { if (S[i] == '(') stack.Push(i + 1); else count = stack.Pop(); if (right && count == K) { ans = i + 1; break; } if (!right && i + 1 == K) { ans = count; break; } } Console.WriteLine(ans); } } }