#include <bits/stdc++.h>
const int N = 5e5 + 5;
int n, a[N], b[N];
char s[N];
int checkPre(int n, int &flg) {
  int cnt = 0;
  for (int i = 1; i <= n; ++i)
    if ((cnt += (s[i] == '(' ? 1 : -1)) < 0) flg = 0;
  return cnt;
}
int checkSuc(int n, int &flg) {
  int cnt = 0;
  for (int i = n; i >= 1; --i)
    if ((cnt += (s[i] == '(' ? -1 : 1)) < 0) flg = 0;
  return cnt;
}
int main() {
  scanf("%d", &n);
  int tot = 0;
  while (n--) {
    scanf("%s", s + 1);
    int len = strlen(s + 1), pre = 1, suc = 1;
    int cnt1 = checkPre(len, pre);
    int cnt2 = checkSuc(len, suc);
    if (pre && suc)
      ++tot;
    else if (pre)
      ++a[cnt1];
    else if (suc)
      ++b[cnt2];
  }
  int ans = tot >> 1;
  for (int i = 0; i < N; ++i) ans += std::min(a[i], b[i]);
  printf("%d\n", ans);
  return 0;
}
