#include <bits/stdc++.h>
using namespace std;
long long ng[1010000], pst[1010000], mrk[1010000], a[1010000];
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
  long long n, f1, f2, l, c, cnt, ans = 0;
  string s;
  cin >> n;
  for (long long i = 0; i < n; i++) {
    cin >> s;
    l = s.length();
    f1 = 0;
    f2 = 0;
    c = 0;
    for (long long j = 0; j < l; j++) {
      if (s[j] == '(')
        c++;
      else
        c--;
      if (c < 0) f1 = 1;
    }
    cnt = c;
    c = 0;
    for (long long j = l - 1; j >= 0; j--) {
      if (s[j] == ')')
        c++;
      else
        c--;
      if (c < 0) {
        f2 = 1;
        break;
      }
    }
    if (!f1 || !f2) {
      if (cnt < 0)
        ng[abs(cnt)]++;
      else
        pst[cnt]++;
      a[i] = cnt;
    } else
      mrk[i] = 1;
  }
  for (long long i = 0; i < n; i++) {
    if (mrk[i]) continue;
    if (a[i] > 0 && pst[a[i]]) {
      if (ng[a[i]]) {
        ng[a[i]]--;
        ans++;
      }
      pst[a[i]]--;
    } else if (a[i] < 0 && ng[-a[i]]) {
      if (pst[-a[i]]) {
        pst[-a[i]]--;
        ans++;
      }
      ng[-a[i]]--;
    } else if (pst[a[i]] > 1) {
      if (pst[0] >= 2) {
        pst[0] -= 2;
        ans++;
      }
    }
  }
  cout << ans << endl;
}
