using System; using System.Collections.Generic; using System.Text; class Program { public void Proc() { Reader.IsDebug = false; int[] intArray = Reader.GetInt(); int textLen = intArray[0]; int target = intArray[1]; string inpt = Reader.ReadLine(); Stack stk = new Stack(); for (int i = 0; i < inpt.Length; i++) { PartOfText pt = new PartOfText(); pt.Pos = i + 1; pt.CharOfText = inpt[i]; if (pt.CharOfText == '(') { stk.Push(pt); } else { PartOfText pair = stk.Pop(); if (pt.Pos == target) { Console.WriteLine(pair.Pos); return; } else if (pair.Pos == target) { Console.WriteLine(pt.Pos); return; } } } } public class PartOfText { public char CharOfText; public int Pos = 0; } public class Reader { public static bool IsDebug = true; private static String PlainInput = @" 20 5 ((((((()))))))(()()) "; private static System.IO.StringReader Sr = null; public static string ReadLine() { if (IsDebug) { if (Sr == null) { Sr = new System.IO.StringReader(PlainInput.Trim()); } return Sr.ReadLine(); } else { return Console.ReadLine(); } } public static int[] GetInt(char delimiter = ' ', bool trim = false) { string inptStr = ReadLine(); if (trim) { inptStr = inptStr.Trim(); } string[] inpt = inptStr.Split(delimiter); int[] ret = new int[inpt.Length]; for (int i = 0; i < inpt.Length; i++) { ret[i] = int.Parse(inpt[i]); } return ret; } } static void Main() { Program prg = new Program(); prg.Proc(); } }