#include <bits/stdc++.h>
using namespace std;
int score(string str) {}
int main() {
  int n, i;
  string str;
  cin >> n;
  unordered_map<int, int> mp;
  mp[0] = 0;
  for (i = 0; i < n; i++) {
    cin >> str;
    vector<bool> v;
    for (int i = 0; i < str.size(); i++) {
      if (str[i] == '(')
        v.push_back(true);
      else {
        if (v.size() == 0 || v[v.size() - 1] == false)
          v.push_back(false);
        else
          v.pop_back();
      }
    }
    bool flag = true;
    for (int i = 1; i < v.size(); i++) {
      if (v[i] != v[0]) flag = false;
    }
    if (flag) {
      if (v.size() == 0)
        mp[0]++;
      else if (v[0] == true)
        mp[v.size()]++;
      else
        mp[-1 * v.size()]++;
    }
  }
  int ans = 0;
  for (auto p : mp) {
    if (p.first > 0) {
      auto pp = mp.find(-1 * p.first);
      if (pp != mp.end()) ans += min(p.second, mp[-1 * p.first]);
    }
  }
  ans += (mp[0] / 2);
  cout << ans;
  return 0;
}
