#include <bits/stdc++.h>
using namespace std;
int isGood(string& s, int im) {
  if (im < 0) {
    for (int i = 0; i < s.length() && im < 0; i++) {
      if (s[i] == ')') s[i] = 'x', im++;
    }
  } else if (im > 0) {
    for (int i = s.length() - 1; i >= 0 && im > 0; i--)
      if (s[i] == '(') s[i] = 'x', im--;
  }
  int c = 0;
  for (int i = 0; i < s.length(); i++) {
    if (s[i] == '(')
      c++;
    else if (s[i] == ')')
      c--;
    if (c < 0) return 0;
  }
  return 1;
}
const int ten6 = 1000000;
int a[ten6 + 1] = {0};
int main() {
  int n;
  cin >> n;
  for (int i = 0; i <= ten6; i++) a[i] = 0;
  for (int i = 0; i < n; i++) {
    string s;
    cin >> s;
    int rb = count(s.begin(), s.end(), ')');
    int fb = count(s.begin(), s.end(), '(');
    if (isGood(s, fb - rb)) {
      a[fb - rb + (ten6 / 2)] += 1;
    }
  }
  int ans = 0;
  for (int i = ten6 / 2; i <= ten6; i++) {
    if (i == (ten6 - i))
      ans += a[i] / 2;
    else
      ans += min(a[i], a[ten6 - i]);
  }
  cout << ans;
  return 0;
}
