#include <bits/stdc++.h>   using namespace std;   int main() {     multiset<long long> x, y;     long long n, closing = 0, count = 0, i, j, pair = 0;     cin >> n;     string ss;     for (i = 0; i < n; i++) {       stack<char> s;       closing = 0;       cin >> ss;       for (j = 0; j < ss.length(); j++) {         if (ss[j] ==  )  && s.size() == 0) closing++;         if (ss[j] ==  ( ) s.push(ss[j]);         if (ss[j] ==  )  && s.size() != 0) s.pop();       }       if (closing == 0 && s.size() > 0) x.insert(s.size());       if (closing > 0 && s.size() == 0) y.insert(closing);       if (closing == 0 && s.size() == 0) count++;     }     for (auto i : x) {       if (y.find(i) != y.end()) {         pair++;         y.erase(y.find(i));       }     }     cout << pair + count / 2;   }   