#include <bits/stdc++.h>
using namespace std;
const int maxn = 500005;
const int INF = 0x3f3f3f3f;
const int mod = 998244353;
const double eps = 1e-10;
const double Pi = acos(-1.0);
int n, l[maxn], r[maxn];
char ss[maxn];
int main() {
  scanf("%d", &n);
  memset(l, 0, sizeof(l));
  memset(r, 0, sizeof(r));
  int cnt = 0;
  while (n--) {
    scanf("%s", &ss);
    int len = strlen(ss), ri = 0, le = 0;
    for (int i = 0; i < len; i++) {
      if (ss[i] == '(') {
        le++;
      } else {
        if (le > 0) {
          le--;
        } else {
          ri++;
        }
      }
    }
    if (le > 0 && ri > 0) {
      continue;
    }
    if (le == 0 && ri == 0) {
      cnt++;
    } else if (le == 0) {
      r[ri]++;
    } else {
      l[le]++;
    }
  }
  int ret = 0;
  for (int i = 1; i <= 500000; i++) {
    ret += min(r[i], l[i]);
  }
  ret += (cnt / 2);
  printf("%d\n", ret);
  return 0;
}
