#include <iostream>
#include <string>
#include <stack>
#include <algorithm>
using namespace std;
int main() {
ios::sync_with_stdio(0);
cin.tie(0);
string s;
cin >> s;
stack<char> sta;
int res=0;
for(int i=0; i<s.length(); i++) {
//파이프 시작
if(s[i]=='(') sta.push(s[i]);
else {
sta.pop();
//레이저
if(s[i-1]=='(') res+=sta.size();
//파이프 끝
else res+=1;
}
}
cout << res;
}
To embed this project on your website, copy the following code and paste it into your website's HTML: