#include <bits/stdc++.h>
using namespace std;
int main() {
  ios::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  int n;
  cin >> n;
  vector<int> cnt((int)5e5 + 1);
  vector<int> neg;
  int ans = 0;
  for (int i = 0; i < n; ++i) {
    string s;
    cin >> s;
    int bal = 0, minn = 0;
    for (int j = 0; j < s.size(); ++j) {
      if (s[j] == ')') {
        --bal;
      } else {
        ++bal;
      }
      minn = min(minn, bal);
    }
    if (bal != minn and minn) {
      continue;
    }
    if (bal >= 0) {
      ++cnt[bal];
    } else {
      neg.push_back(bal);
    }
  }
  for (int x : neg) {
    if (cnt[-x]) {
      ++ans;
      --cnt[-x];
    }
  }
  cout << ans + cnt[0] / 2;
  return 0;
}
