#include <bits/stdc++.h>
using namespace std;
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  cout.tie(NULL);
  long long n;
  cin >> n;
  string s[n];
  map<long long, long long> pam;
  map<long long, long long> oam;
  long long ans = 0, cnt = 0;
  for (long long i = 0; i < n; i++) {
    cin >> s[i];
    long long o = 0, c = 0;
    for (long long j = 0; j < s[i].length(); j++) {
      if (s[i][j] == '(') {
        o++;
      } else {
        if (o == 0)
          c--;
        else
          o--;
      }
    }
    if (o == 0 and c == 0)
      cnt++;
    else if (o > 0 and c == 0) {
      pam[o]++;
    } else if (c < 0 and o == 0) {
      oam[-c]++;
    }
  }
  ans += cnt / 2;
  for (auto p = pam.begin(); p != pam.end(); ++p) {
    long long v = (*p).first;
    ans += min(pam[v], oam[v]);
  }
  cout << ans;
}
