using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Threading.Tasks; namespace yukicorder22 { class Program { static void Main(string[] args) { int[] N = Console.ReadLine().Split(' ').Select(n => int.Parse(n)).ToArray(); char[] line = Console.ReadLine().ToCharArray(); int[] table = new int[N[0]]; int cnt = 1; for (var i = 0; i < N[0]; i++) { var kakko = 1; var j = i + 1; while (table[i] == 0 && kakko != 0 && i < N[0] - 1) { if (line[j] == ')') kakko--; if (line[j] == '(') kakko++; if(kakko == 0) { table[i] = j + 1; table[j] = i + 1; cnt++; break; } else { j++; } } } // Console.WriteLine(string.Join(" ",table)); Console.WriteLine(table[N[1] -1]); Console.ReadKey(); } } }