#include <bits/stdc++.h>
using namespace std;
int main() {
  int n;
  cin >> n;
  vector<string> strs(n);
  for (int i = 0; i < n; i++) {
    cin >> strs[i];
  }
  map<int, int> counters;
  set<int> cont;
  vector<int> contV;
  int specNuls = 0;
  for (int i = 0; i < n; i++) {
    string curr = strs[i];
    int q = 0;
    bool neg = false;
    for (int j = 0; j < curr.size(); j++) {
      if (curr[j] == '(') {
        q++;
      } else {
        q--;
      }
      if (q < 0) {
        neg = true;
      }
    }
    if (q >= 0 && neg) {
      continue;
    }
    if (q < 0 && curr[curr.size() - 1] == '(') {
      continue;
    }
    if (q > 0 && curr[0] == ')') {
      continue;
    }
    bool llll = false;
    if (q < 0) {
      int m = 0;
      for (int l = curr.size() - 1; l >= 0; l--) {
        if (curr[l] == '(') {
          m++;
        } else {
          m--;
        }
        if (m > 0) {
          llll = true;
          break;
        }
      }
    }
    if (llll) {
      continue;
    }
    if (cont.count(-q) == 0 && cont.count(q) == 0) {
      cont.insert(q);
      contV.push_back(q);
    }
    counters[q]++;
  }
  int answ = 0;
  for (int i = 0; i < contV.size(); i++) {
    int num = contV[i];
    if (num != 0) {
      if (counters.count(num) != 0 && counters.count(-num) != 0) {
        answ += min(counters[num], counters[-num]);
      }
    } else {
      answ += counters[0] / 2;
    }
  }
  cout << answ << endl;
  return 0;
}
