using System; class Program { static void Main() { string[] s = Console.ReadLine().Split(); int n = int.Parse(s[0]); int k = int.Parse(s[1]); char[] c = Console.ReadLine().ToCharArray(); int a = 0; int b = 0; int ans = 0; if (c[k - 1] == '(') { a++; for (int i = k; ; i++) { if (c[i] == ')') { b++; if (a == b) { ans = k + 2 * a - 1; break; } } else a++; } } else { b++; for (int i = k - 2; ; i--) { if (c[i] == '(') { a++; if (a == b) { ans = k - 2 * a + 1; break; } } else b++; } } Console.WriteLine(ans); } }