정답 코드
#include <iostream>
#include <stack>
using namespace std;
int n, cnt;
string s;
int main() {
ios_base::sync_with_stdio(false);
cin.tie(NULL);
cout.tie(NULL);
cin>>n;
for(int i=0; i<n; i++) {
stack<int> stk;
cin>>s;
stk.push(s[0]);
for(int j=1; j<s.length(); j++) {
if(stk.empty()) {
stk.push(s[j]);
}
else if(char(stk.top())==s[j]) {
stk.pop();
}
else {
stk.push(s[j]);
}
}
if(stk.empty()) {
cnt++;
}
}
cout<<cnt<<'\n';
return 0;
}