#include <bits/stdc++.h>
using namespace std;
int n, minus[100002], plus[100002];
pair<int, int> p[100002];
int main() {
  int i, m, j;
  cin >> n;
  string s;
  int sum, mi;
  for (i = 0; i < n; i++) {
    cin >> s;
    sum = 0;
    mi = 100001;
    m = s.length();
    for (int j = 0; j < m; j++) {
      if (s[j] == '(') {
        sum++;
      } else {
        sum--;
      }
      if (sum < mi) {
        mi = sum;
      }
    }
    p[i].first = sum;
    p[i].second = mi;
  }
  sort(p, p + n);
  i = 0;
  j = n - 1;
  sum = 0;
  while (i < j) {
    if (p[i].first > 0 || p[j].first < 0) break;
    if (-p[i].first > p[j].first) {
      i++;
      continue;
    }
    if (-p[i].first < p[j].first) {
      j--;
      continue;
    }
    if (p[i].second + p[j].first < 0) {
      i++;
      continue;
    }
    if (p[j].second < 0) {
      j--;
      continue;
    }
    i++;
    j--;
    sum++;
  }
  cout << sum;
  return 0;
}
