#include <bits/stdc++.h>
using namespace std;
const int xy = 5000000;
string s;
int n, a, b, len, tong[10000000], ans;
int main() {
  scanf("%d", &n);
  for (int i = 1; i <= n; i++) {
    cin >> s;
    a = 0;
    b = 0;
    len = s.length();
    for (int j = 0; j < len; j++) {
      if (s[j] == '(')
        a++;
      else if (a)
        a--;
      else
        b++;
    }
    if (a && b)
      continue;
    else if (a)
      tong[xy + a]++;
    else if (b)
      tong[xy - b]++;
    else
      tong[xy]++;
  }
  ans = tong[xy] >> 1;
  for (int i = xy; i >= 1; i--)
    if (tong[xy - i] && tong[xy + i]) ans += min(tong[xy + i], tong[xy - i]);
  cout << ans;
  return 0;
}
