#include <bits/stdc++.h>
using namespace std;
long long x;
long long y;
void check(string s) {
  x = 0;
  y = 0;
  for (long long i = 0; i < (long long)s.size(); i++) {
    if (s[i] == '(') {
      x++;
    }
    if (s[i] == ')') {
      if (x)
        x--;
      else
        y++;
    }
  }
}
signed main() {
  std::ios::sync_with_stdio(false), cin.tie(0), cout.tie(0);
  long long n;
  cin >> n;
  string s;
  vector<long long> pre, suf;
  long long zeros = 0;
  for (long long i = 0; i < n; i++) {
    cin >> s;
    check(s);
    if (x == 0 and y == 0)
      zeros++;
    else if (x == 0)
      suf.push_back(y);
    else if (y == 0)
      pre.push_back(x);
  }
  long long ans = zeros / 2;
  for (long long i = 0; i < (long long)pre.size(); i++)
    for (long long j = 0; j < (long long)suf.size(); j++)
      if (pre[i] == suf[j]) {
        ans++, suf[j] = 0;
        break;
      }
  cout << ans;
  return 0;
}
