#include <iostream>
#include <string>
#include <stack>
using namespace std;
int main() {
std::stack<int> temp;
const std::string str("(x+y)*x + x * (12*(x-y))");
for (std::string::const_iterator iter = str.begin(); iter != str.end(); iter++) {
if ('(' == *iter) {
temp.push((int)(iter - str.begin()));
}
if (')' == *iter) {
std::cout<<temp.top()<<" - "<<(int)(iter - str.begin())<<std::endl;
temp.pop();
}
}
return 0;
}