#include <bits/stdc++.h>
using namespace std;
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
inline int rand(int x, int y) {
  ++y;
  return (rng() % (y - x)) + x;
}
int n, co[100002], ans;
string A[100002];
bool prefix[100002], suffix[100002], m[100002];
set<pair<int, int> > pre, suf;
void erse(int i) {
  if (prefix[i]) pre.erase(pre.find(pair<int, int>(co[i], i)));
  if (suffix[i]) suf.erase(suf.find(pair<int, int>(-co[i], i)));
}
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  cin >> n;
  for (int i = 0; i < n; i++) cin >> A[i];
  for (int i = 0; i < n; i++) {
    int open = 0;
    bool can = 1;
    for (int j = 0; j < A[i].length(); j++) {
      if (A[i][j] == '(')
        open++;
      else
        open--;
      if (open < 0) can = 0;
      if (A[i][j] == '(')
        co[i]++;
      else
        co[i]--;
    }
    prefix[i] = can;
    open = 0, can = 1;
    for (int j = A[i].length() - 1; j >= 0; j--) {
      if (A[i][j] == ')')
        open++;
      else
        open--;
      if (open < 0) can = 0;
    }
    suffix[i] = can;
    if (prefix[i]) pre.insert(pair<int, int>(co[i], i));
    if (suffix[i]) suf.insert(pair<int, int>(-co[i], i));
  }
  for (int i = 0; i < n; i++) {
    if (m[i]) continue;
    if (prefix[i]) {
      auto itr = suf.lower_bound(pair<int, int>(co[i], 0));
      while (itr != suf.end() && ((*itr).second == i) && (*itr).first == co[i])
        itr++;
      if (itr != suf.end()) {
        if (co[i] - (*itr).first == 0) {
          ans++;
          m[(*itr).second] = 1;
          m[i] = 1;
          erse(i);
          erse((*itr).second);
        }
      }
    }
    if (m[i] == 0 && suffix[i]) {
      auto itr = pre.lower_bound(pair<int, int>(-co[i], 0));
      while (itr != pre.end() && ((*itr).second == i) && (*itr).first == co[i])
        itr++;
      if (itr != pre.end()) {
        if (-co[i] + (*itr).first == 0) {
          ans++;
          m[(*itr).second] = 1;
          m[i] = 1;
          erse(i);
          erse((*itr).second);
        }
      }
    }
  }
  cout << ans << "\n";
}
