class Program { static void Main(string[] args) { string[] str = Console.ReadLine().Split(' '); string parentheses = Console.ReadLine(); int count= 0; List list = new List(); if (parentheses[int.Parse(str[1])-1] == ')') { var rev = parentheses.Reverse().ToArray(); parentheses = string.Join("", rev); } for(int i = 0; i < int.Parse(str[0]); i++) { if (parentheses[i] == '(') { count++; } else { count--; } list.Add(count); } int ans = 0; for(int i = 0; i < list.Count; i++) { if (list[i] != 0) { continue; } if (parentheses[int.Parse(str[0]) - int.Parse(str[1])] == '(') { ans = i; } else { ans = int.Parse(str[1])-i; } } Console.WriteLine(ans); } }