using System; using System.Linq; class No22 { static void Main() { var num = Console.ReadLine().Split(' ').Select(x => Int32.Parse(x)).ToArray(); var line = Console.ReadLine().ToCharArray(); var isAdd = line[num[1] - 1] == '(' ? true : false; var i = isAdd ? 0 : line.Length - 1; var firstChar = isAdd ? line[0] : line[line.Length - 1]; var beforeChar = firstChar; var shindo = 1; var myShindo = ((isAdd && num[1] == 1) || (!isAdd && num[1] == line.Length)) ? 1 : 0; while (true) { i = isAdd ? i + 1 : i - 1; if (line[i] == beforeChar) { if (line[i] == firstChar) shindo++; else shindo--; } if (i + 1 == num[1]) myShindo = shindo; if (isAdd) { if (shindo == myShindo && line[i] == ')') break; } else { if (shindo == myShindo && line[i] == '(') break; } beforeChar = line[i]; } Console.WriteLine(i + 1); } }