#include <bits/stdc++.h>
using namespace std;
void oj() {}
signed main() {
  ios::sync_with_stdio(0);
  cin.tie(0);
  ;
  oj();
  long long n, zc = 0, fans = 0;
  cin >> n;
  map<long long, long long> m1, m2;
  while (n--) {
    string s;
    cin >> s;
    long long cnt = 0, mini = 0;
    for (long long i = 0; i < s.length(); i++) {
      if (s[i] == '(')
        cnt++;
      else
        cnt--;
      mini = min(cnt, mini);
    }
    if (mini < 0) {
      stack<char> stk;
      bool ok = true;
      for (long long i = 0; i < s.size(); i++) {
        if (s[i] == ')') {
          if (stk.size() != 0) stk.pop();
        } else
          stk.push(s[i]);
      }
      if (stk.size() == 0) m2[cnt]++;
    } else {
      if (cnt == 0)
        zc++;
      else
        m1[-1 * cnt]++;
    }
  }
  for (auto x : m1)
    if (m2[x.first]) fans += min(x.second, m2[x.first]);
  cout << fans + zc / 2;
  return 0;
}
