#include <bits/stdc++.h>
using namespace std;
long long MOD = 998244353;
int a[1000005];
int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  int n;
  cin >> n;
  string s;
  for (long long i = 0; i < n; i++) {
    cin >> s;
    int t = 0, mi = 0;
    for (long long j = 0; j < s.size(); j++) {
      if (s[j] == '(')
        t += 1;
      else
        t -= 1;
      mi = min(mi, t);
    }
    if ((t > 0 && mi == 0) || t == mi) a[t + 500002]++;
  }
  int ans = 0;
  for (long long i = 0; i < 500003; i++) {
    if (i == 500002)
      ans += a[i] / 2;
    else
      ans += min(a[i], a[1000004 - i]);
  }
  cout << ans;
  return 0;
}
