#include <bits/stdc++.h>
using namespace std;
int main() {
  int n;
  cin >> n;
  vector<int> negs;
  set<pair<int, int>> poses;
  map<int, int> posTotals;
  vector<pair<int, int>> equals;
  for (int i = 0; i < n; i++) {
    string seq;
    cin >> seq;
    int diff = 0;
    int diffMax = 0;
    for (int j = 0; j < seq.length(); j++) {
      if (seq[j] == ')')
        diff += 1;
      else
        diff -= 1;
      diffMax = max(diff, diffMax);
    }
    int total = -diff;
    if (total < 0 && diffMax == -total)
      negs.push_back(total);
    else if (total > 0 && diffMax <= 0) {
      if (posTotals.count(total))
        posTotals[total]++;
      else
        posTotals[total] = 1;
    } else if (total == 0 && diffMax <= 0)
      equals.push_back(make_pair(diffMax, i));
  }
  int c = 0;
  c += equals.size() / 2;
  for (auto e : negs) {
    if (posTotals.count(-e) && posTotals[-e] > 0) {
      posTotals[-e]--;
      c++;
    }
  }
  cout << c << endl;
  return 0;
}
