#include <bits/stdc++.h>
using namespace std;
int mp_open[500005] = {0}, mp_close[500005] = {0}, khali = 0;
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
  int ans = 0;
  int n;
  cin >> n;
  string x;
  stack<char> st1;
  for (int i = 0; i < n; ++i) {
    cin >> x;
    int l = x.length();
    for (int i = 0; i < l; ++i) {
      if (st1.size() == 0)
        st1.push(x[i]);
      else if (st1.top() == '(' && x[i] == ')') {
        st1.pop();
      } else
        st1.push(x[i]);
    }
    int ctropen = 0, ctrclose = 0;
    while (!st1.empty()) {
      if (st1.top() == '(')
        ctropen++;
      else
        ctrclose++;
      st1.pop();
    }
    if (ctropen > 0 && ctrclose > 0) continue;
    if (ctropen > 0) {
      if (mp_close[ctropen] > 0) {
        mp_close[ctropen]--;
        ans++;
      } else
        mp_open[ctropen]++;
    }
    if (ctrclose > 0) {
      if (mp_open[ctrclose] > 0) {
        mp_open[ctrclose]--;
        ans++;
      } else
        mp_close[ctrclose]++;
    }
    if (ctropen == 0 && ctrclose == 0) khali++;
  }
  ans = ans + khali / 2;
  cout << ans << '\n';
  return 0;
}
