#include <bits/stdc++.h>
using std::cerr;
using std::copy;
using std::fill;
using std::max;
using std::min;
using std::swap;
int frt[1000009], a[1000009];
int head, fp, sum;
int m, n;
char s[1000009];
int main() {
  scanf("%d", &n);
  for (int i = 0; i < n; i++) {
    scanf("%s", s);
    m = strlen(s);
    sum = 0;
    frt[i] = 100000;
    for (int j = 0; j < m; j++) {
      sum += (s[j] == ')') ? -1 : 1;
      frt[i] = min(sum, frt[i]);
    }
    if (sum >= 0) {
      if (frt[i] >= 0) a[fp++] = sum;
    } else {
      if (frt[i] == sum) a[fp++] = sum;
    }
  }
  int ans = 0;
  std::sort(a, a + fp);
  while (head + 1 < fp) {
    if (a[head] == -a[fp - 1])
      head++, fp--, ans++;
    else if (abs(a[head]) > abs(a[fp - 1]))
      head++;
    else
      fp--;
  }
  printf("%d\n", ans);
  return 0;
}
