#include <bits/stdc++.h>
int a[500001], b[500001];
using namespace std;
int main() {
  int n;
  cin >> n;
  string s;
  int ans = 0, k = 0;
  for (int i = 0; i < n; i++) {
    cin >> s;
    int a1 = 0, b1 = 0, len = s.size();
    for (int j = 0; j < len; j++)
      if (s[j] == '(')
        a1++;
      else
        b1++;
    int bal = 0;
    for (int j = 0; j < len; j++) {
      if (s[j] == '(')
        bal++;
      else {
        if (bal > 0) {
          bal--;
          a1--;
          b1--;
        }
      }
    }
    if (a1 && b1) continue;
    if (bal == 0 && a1 == 0 && b1 == 0) k++;
    if (a1 == 0)
      b[b1]++;
    else
      a[a1]++;
  }
  ans = k / 2;
  for (int i = 1; i < 500001; i++) ans += min(a[i], b[i]);
  cout << ans;
  return 0;
}
