#include <bits/stdc++.h>
using namespace std;

int main() {
    ios::sync_with_stdio(0);
    cin.tie(0);
    int res=0;
    int n;
    cin >> n;
    while(n--){
        string a;
        cin >> a;
        stack<char> s;
        for(auto c:a){
            //스택이 안비었고 맨위가 같음
            if(!s.empty() && s.top()==c) s.pop();
            //다름
            else s.push(c);
        }
        if(s.empty()) res++;
    }
    cout << res;
    return 0;
}

Embed on website

To embed this project on your website, copy the following code and paste it into your website's HTML: