#include <bits/stdc++.h>
using namespace std;
const int INF = ((long long)1 << 31) - 1;
int main() {
  int n;
  cin >> n;
  vector<string> v(n);
  vector<int> correct;
  vector<pair<int, int>> open, close;
  multiset<int> op, cl;
  for (int i = 0; i < n; ++i) {
    cin >> v[i];
    string temp = v[i];
    int bal = 0, close_bal = 0;
    bool was_neg = false;
    for (int j = 0; j < temp.size(); ++j) {
      if (temp[j] == '(') {
        ++bal;
      } else {
        if (bal == 0) {
          was_neg = true;
        } else {
          --bal;
        }
      }
    }
    for (int j = temp.size() - 1; j >= 0; --j) {
      if (temp[j] == '(') {
        --close_bal;
        close_bal = max(close_bal, 0);
      } else {
        ++close_bal;
      }
    }
    if (was_neg) {
      if (bal == 0) {
        cl.insert(close_bal);
        close.push_back({i, close_bal});
      }
    } else if (bal > 0) {
      op.insert(bal);
      open.push_back({i, bal});
    } else {
      correct.push_back(i);
    }
  }
  int ans = correct.size() / 2;
  sort(open.begin(), open.end(), [](pair<int, int> p1, pair<int, int> p2) {
    if (p1.second == p2.second) {
      return p1.first < p2.first;
    }
    return p1.second < p2.second;
  });
  sort(close.begin(), close.end(), [](pair<int, int> p1, pair<int, int> p2) {
    if (p1.second == p2.second) {
      return p1.first < p2.first;
    }
    return p1.second < p2.second;
  });
  int i = 0, j = 0;
  while (i < open.size() && j < close.size()) {
    if (open[i].second == close[j].second) {
      ++ans, ++i, ++j;
    } else if (open[i].second < close[j].second) {
      ++i;
    } else {
      ++j;
    }
  }
  cout << ans;
  return 0;
}
