#include <bits/stdc++.h>
using namespace std;
int num0[500010], num1[500010];
char s[500010];
int cnt, n, ans;
int main() {
  scanf("%d", &n);
  for (int i = 1; i <= n; i++) {
    scanf("%s", s);
    int len = strlen(s);
    int x = 0, mi = 0;
    for (int j = 0; j < len; j++) {
      if (s[j] == '(')
        x++;
      else
        x--;
      mi = min(mi, x);
    }
    if (x > 0 && mi >= 0)
      num0[x]++;
    else if (x == 0 && mi == 0)
      cnt++;
    else if (x < 0 && mi >= x)
      num1[-x]++;
  }
  for (int i = 1; i <= 500000; i++) ans += min(num0[i], num1[i]);
  ans += cnt / 2;
  printf("%d\n", ans);
  return 0;
}
