#include <bits/stdc++.h>
using namespace std;
const int N = 5e6 + 5;
int i, j, k, a, b, c, d, x, y, z, f, cnt, p, n, m, tc, ans, cur, mn, mx;
string s, str, s1, s2, s3, st;
int r[N];
int l[N];
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  cin >> n;
  while (n--) {
    cin >> s;
    cur = 0;
    mn = 0;
    for (char c : s) {
      if (c == '(')
        cur++;
      else
        cur--;
      mn = min(cur, mn);
    }
    if (cur == 0) {
      if (mn >= 0) {
        cnt++;
      }
    } else {
      if (cur < 0) {
        if (mn == cur) {
          r[-cur]++;
        }
      } else if (mn >= 0) {
        l[cur]++;
      }
    }
  }
  int ans = cnt / 2;
  for (int i = 0; i < N; i++) {
    ans += min(l[i], r[i]);
  }
  cout << ans << endl;
  return 0;
}
