#include <bits/stdc++.h>
using namespace std;
signed main() {
  long long n;
  cin >> n;
  vector<long long> left;
  vector<long long> right;
  long long ok = 0;
  for (long long i = 0; i < n; i++) {
    string s;
    cin >> s;
    long long l = 0, r = 0;
    for (auto it : s) {
      if (it == '(') {
        l++;
      } else if (it == ')' && l != 0) {
        l--;
      } else {
        r++;
      }
    }
    if (r == 0 && l != 0) {
      left.push_back(l);
    }
    if (r != 0 && l == 0) {
      right.push_back(r);
    }
    if (r == 0 && l == 0) {
      ok++;
    }
  }
  sort(left.begin(), left.end());
  sort(right.begin(), right.end());
  long long r = 0;
  long long ans = 0;
  for (long long l = 0; l < left.size(); l++) {
    long long cur = left[l];
    while (r < right.size() && right[r] < cur) {
      r++;
    }
    if (r < right.size() && right[r] == cur) {
      r++;
      ans++;
    }
    if (r == right.size()) break;
  }
  ans += ok / 2;
  cout << ans << endl;
}
