0
1
mirror of https://git.sb/baoshuo/OI-codes.git synced 2024-12-25 06:51:58 +00:00
OI-codes/XJOI/contest/21med/A/A.cpp

27 lines
477 B
C++
Raw Normal View History

#include <bits/stdc++.h>
using namespace std;
int n, p;
string s;
stack<int> st;
int main() {
cin >> n >> p >> s;
s = ' ' + s;
for (int i = 1; i < s.size(); i++) {
if (s[i] == '{') {
st.push(i);
} else if (st.top() == p) {
cout << i << endl;
exit(0);
} else if (i == p) {
cout << st.top() << endl;
exit(0);
} else {
st.pop();
}
}
return 0;
}