#include <string>
#include <vector>
#include <stack>
#include <iostream>
using namespace std;
int solution(string arrangement) {
int answer = 0;
string before;
string now;
stack<char>left;
left.push(arrangement[0]);
for(int i= 1 ; i < arrangement.length(); i++){
before = arrangement[i-1];
now = arrangement[i];
if(before == ")" && now ==")"){
left.pop();
answer+=1;
continue;
}
if(arrangement[i] == '(')
left.push(arrangement[i]);
else{
cout << left.top();
left.pop();
answer+=left.size();
}
}
return answer;
}