n,m = gets.split.map(&:to_i) s = gets.chomp.split("") i = 0 j = 1 loop do if s[i] == "(" && s[j] == ")" s[i] = "" s[j] = "" if i+1 == m || j+1 == m if i+1 == m p j+1 else p i+1 end break end i = 0 j = 1 elsif s[i] == "(" && s[j] == "(" if s[j-1] == "" i = j j += 1 else i += 1 j += 1 end elsif s[i] == "(" && s[j] == "" j += 1 elsif s[i] == "" i += 1 j += 1 end i = 0 if i == n-1 j = 1 if j == n-1 end