using System; using System.Collections.Generic; using System.Linq; namespace Yukicoder { class Program { static void Main(string[] args) { var line = Console.ReadLine().Split(' '); int N = int.Parse(line[0]); int K = int.Parse(line[1]) - 1; List list = new List(); var kakko = Console.ReadLine() .Select( x => x == '(' ? 0 : 1 ); list.AddRange(kakko); while (true) { int lastKakko = 0; for (int i = 0; i < N; i++) { if(list[i] == 0) { lastKakko = i; continue; } if(list[i] == 1) { list[lastKakko] = -1; list[i] = -1; if(lastKakko == K) { Console.WriteLine(i + 1); return; }else if(i == K) { Console.WriteLine(lastKakko + 1); return; } break; } } } } } }