#include <bits/stdc++.h>
using namespace std;
int main() {
  int n;
  cin >> n;
  int z = 0;
  vector<int> pos, neg;
  for (int i = 0; (i) < (int)(n); (i)++) {
    string s;
    cin >> s;
    int c = 0;
    for (int j = 0; (j) < (int)(s.size()); (j)++) {
      c += (s[j] == '(' ? 1 : -1);
    }
    if (c > 0) {
      int acc = 0;
      bool ng = false;
      for (int j = 0; (j) < (int)(s.size()); (j)++) {
        acc += (s[j] == '(' ? 1 : -1);
        if (acc < 0) {
          ng = true;
          break;
        }
      }
      if (!ng) {
        pos.push_back(acc);
      }
    } else if (c < 0) {
      int acc = 0;
      bool ng = false;
      for (int j = (int)s.size() - 1; j >= 0; j--) {
        acc += (s[j] == ')' ? 1 : -1);
        if (acc < 0) {
          ng = true;
          break;
        }
      }
      if (!ng) {
        neg.push_back(acc);
      }
    } else {
      int acc = 0;
      bool ng = false;
      for (int j = 0; (j) < (int)(s.size()); (j)++) {
        acc += (s[j] == '(' ? 1 : -1);
        if (acc < 0) {
          ng = true;
          break;
        }
      }
      if (!ng) {
        z++;
      }
    }
  }
  int ans = z / 2;
  int pp = 0, np = 0;
  sort(pos.begin(), pos.end());
  sort(neg.begin(), neg.end());
  while (pp < pos.size() && np < neg.size()) {
    while (pp < pos.size() && np < neg.size() && pos[pp] == neg[np]) {
      ans++;
      pp++;
      np++;
    }
    while (pp < pos.size() && np < neg.size() && pos[pp] != neg[np]) {
      if (pos[pp] < neg[np]) {
        pp++;
      } else {
        np++;
      }
    }
  }
  printf("%d\n", ans);
  return 0;
}
