#include <bits/stdc++.h>
using namespace std;
long long int nterm(long long int n) { return (n * (n + 1)) / 2LL; }
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  cout.tie(NULL);
  long long int n;
  cin >> n;
  vector<string> v(n);
  for (int i = 0; i < n; i++) {
    cin >> v[i];
  }
  map<int, int> mp1, mp2;
  int cnt = 0, ans = 0;
  for (int i = 0; i < n; i++) {
    string s = v[i];
    int mn = 0, cur = 0, cur2 = 0, mx = 0;
    int m = s.size();
    for (int j = 0; j < m; j++) {
      if (s[j] == '(')
        cur++, cur2++;
      else
        cur--, cur2--;
      cur2 = max(0, cur2);
      mn = min(mn, cur);
      mx = max(mx, cur);
    }
    if (mn == 0 && cur == 0) {
      cnt++;
      continue;
    }
    if (mn != 0 && cur2 != 0) {
      continue;
    } else if (mn == 0) {
      mp2[cur2]++;
    } else {
      mp1[-mn]++;
    }
  }
  ans = cnt / 2;
  for (auto i : mp1) {
    ans += min(i.second, mp2[i.first]);
  }
  cout << ans << '\n';
  return 0;
}
