#include <bits/stdc++.h>
using namespace std;
int main() {
  long long n;
  cin >> n;
  map<long long, long long> cnt;
  for (long long i = 0; i < n; ++i) {
    string s;
    cin >> s;
    long long l = s.length();
    long long cur = 0;
    long long cur_mn = 0;
    for (long long i = 0; i < l; ++i) {
      cur += (s[i] == ')' ? -1 : 1);
      cur_mn = min(cur_mn, cur);
    }
    if (cur >= 0 && cur_mn >= 0 || cur < 0 && cur_mn - cur >= 0) {
      ++cnt[cur];
    }
  }
  long long ans = 0;
  for (auto& p : cnt) {
    ans += min(cnt[p.first], cnt[-(p.first)]);
  }
  cout << ans / 2;
  return 0;
}
