#include <bits/stdc++.h>
using namespace std;
long long cc = 1e9 + 7;
map<int, int> A;
map<int, int>::iterator itr, it;
int main() {
  int n;
  cin >> n;
  for (int i = 0; i < n; i++) {
    string s;
    cin >> s;
    int nn = s.size();
    vector<int> p;
    for (int j = 0; j < nn; j++) {
      int nnn = p.size();
      if (p.size() == 0) {
        if (s[j] == '(')
          p.push_back(1);
        else
          p.push_back(-1);
      } else {
        if (s[j] == ')') {
          if (p[nnn - 1] == 1)
            p.pop_back();
          else
            p.push_back(-1);
        } else {
          p.push_back(1);
        }
      }
    }
    int nnn = p.size();
    if (nnn == 0)
      A[0]++;
    else if (p[0] == p[nnn - 1]) {
      A[(p[0] * nnn)]++;
    }
  }
  int sum = 0;
  for (itr = A.begin(); itr != A.end(); itr++) {
    if (itr->first == 0) {
      sum += (itr->second) / 2;
    } else {
      int yy = itr->first;
      it = A.find(0 - yy);
      if (it != A.end()) {
        sum += (min(itr->second, it->second));
        it->second = 0;
      }
    }
  }
  cout << sum << endl;
}
