using System; using System.Text; using System.Linq; using System.IO; namespace N { class P { static void Main() { Console.SetIn(new StreamReader(Console.OpenStandardInput(10000))); string CSL = Console.ReadLine(); int N = 0; int K = 0; for (int i = 0; i < CSL.Length; i++) { if (CSL[i] == ' ') { N = int.Parse(CSL.Substring(0, i)); K = int.Parse(CSL.Substring(i)); break; } } char[] Text = Console.ReadLine().ToCharArray(); int W_K = 0; int Ans = 0; char T = Text[K - 1]; for (int i = 0; ; i++) { if (Text[i] == '(') W_K++; if (Text[i] == ')') W_K--; if (i == K - 1) break; } if(T=='(') { int W_S = W_K; for(int i=K-1; ;i++) { if (Text[i] == '(') W_S++; if (Text[i] == ')') W_S--; if(W_S==W_K) { Ans = i+1; break; } } } else { int W_S = W_K; for (int i =0; ; i++) { if (W_S == W_K) { Ans = i + 1; break; } if (Text[i] == '(') W_S++; if (Text[i] == ')') W_S--; } } Console.WriteLine(Ans); Console.ReadKey(); } } }