#include <bits/stdc++.h>
using namespace std;
const int maxn = 1e5 + 5;
int n;
string s[maxn];
map<int, pair<int, int>> mp;
int main() {
  ios::sync_with_stdio(false);
  cin.tie(nullptr);
  cin >> n;
  int correct = 0;
  for (int i = 0; i < n; i++) {
    cin >> s[i];
    int balance = 0;
    int min_balance = 0;
    for (char c : s[i]) {
      if (c == '(') {
        balance++;
      } else {
        balance--;
      }
      min_balance = min(min_balance, balance);
    }
    if (min_balance >= 0) {
      if (balance == 0) {
        correct++;
      } else {
        mp[balance].first++;
      }
    } else {
      if (min_balance == balance) {
        mp[-balance].second++;
      }
    }
  }
  int res = correct / 2;
  for (auto& it : mp) {
    res += min(it.second.first, it.second.second);
  }
  cout << res << "\n";
  return 0;
}
