using System; namespace No022_括弧の対応 { class Program { static void Main(string[] args) { string[] input = Console.ReadLine().Split(' '); int n = int.Parse(input[0]); int k = int.Parse(input[1]); string s = "(" + Console.ReadLine() + ")"; int count, level = 0; if (s[k] == '(') { count = k - 1; do { count++; if (s[count] == '(') level++; else level--; } while (level > 0 || s[count] != ')'); } else { count = k + 1; do { count--; if (s[count] == ')') level++; else level--; } while (level > 0 || s[count] != '('); } Console.WriteLine(count.ToString()); } } }