#include <bits/stdc++.h>
using namespace std;
constexpr int MOD = 998244353;
constexpr int MAXN = 2e5 + 42;
int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  int N;
  cin >> N;
  vector<string> V(N);
  for (auto& S : V) {
    cin >> S;
  }
  map<int, int> L, R;
  for (auto& S : V) {
    bool ok = 1;
    int open = 0;
    for (auto c : S) {
      if (c == '(')
        open++;
      else
        open--;
      ok = ok && open >= 0;
    }
    if (ok) {
      L[open]++;
    }
    reverse(S.begin(), S.end());
    ok = 1;
    open = 0;
    for (auto c : S) {
      if (c == ')')
        open++;
      else
        open--;
      ok = ok && open >= 0;
    }
    if (ok) {
      R[open]++;
    }
  }
  int res = L[0] / 2;
  for (auto i : L) {
    if (i.first > 0) {
      res += min(i.second, R[i.first]);
    }
  }
  cout << res << endl;
  return 0;
}
