using System; using System.Linq; using System.Collections; namespace yukicoder_no22 { class MainClass { public static void Main(string[] args) { int[] L1 = Console.ReadLine().Split(' ').Select(x => int.Parse(x)).ToArray(); int N = L1[0]; int K = L1[1] - 1; char[] S = Console.ReadLine().ToCharArray(); int[] X = new int[N]; var stack = new Stack(); for (int i = 0; i < N; i++) { if (S[i] == '(') { stack.Push(i); continue; } if (S[i] == ')') { int index = (int)stack.Pop(); X[index] = i; X[i] = index; continue; } } Console.WriteLine("{0}", X[K] + 1); } } }