#include <bits/stdc++.h>
using namespace std;
long long int maximum(long long int a, long long int b) {
  return (a > b) ? a : b;
}
long long int minimum(long long int a, long long int b) {
  return (a < b) ? a : b;
}
int main() {
  int n;
  cin >> n;
  string br[n + 1], str;
  int minf, mine, ctf, cte;
  vector<int> inc, dec;
  int zero = 0;
  int len = 0;
  unordered_map<char, int> map;
  map[')'] = -1;
  map['('] = 1;
  for (int i = 1; i <= n; i++) {
    cin >> br[i];
    str = br[i];
    len = str.size();
    minf = -1;
    mine = len;
    ctf = 0;
    for (int j = 0; j < str.size(); j++) {
      ctf += map[str[j]];
      if (ctf < 0) minf = j;
    }
    cte = 0;
    for (int j = str.size() - 1; j >= 0; j--) {
      cte += map[str[j]];
      if (cte > 0) mine = j;
    }
    if (str.size() == 1) {
      if (str[0] == '(')
        inc.push_back(1);
      else
        dec.push_back(1);
    } else if (minf == -1 && mine == (len)) {
      zero++;
    } else if (minf == -1) {
      inc.push_back(ctf);
    } else if (mine == (len)) {
      dec.push_back(-ctf);
    }
  }
  sort(inc.begin(), inc.end());
  sort(dec.begin(), dec.end());
  int i = 0, j = 0, ans = 0;
  while (i < inc.size() && j < dec.size()) {
    if (inc[i] == dec[j]) {
      i++;
      j++;
      ans++;
    } else if (inc[i] < dec[j]) {
      i++;
    } else
      j++;
  }
  ans += (zero / 2);
  cout << ans;
  return 0;
}
