#include <bits/stdc++.h>
using namespace std;
map<long long, multiset<pair<long long, long long>>> a;
string s[200000];
long long bal[200000];
long long mn[200000];
void build(long long v) {
  long long bl = 0, mmn = 0;
  for (auto i : s[v]) {
    if (i == '(')
      bl++;
    else
      bl--;
    mmn = min(mmn, bl);
  }
  mn[v] = mmn;
  bal[v] = bl;
}
bool check(multiset<pair<long long, long long>> &s, long long mn,
           long long bal) {
  if (s.size() == 0) return 0;
  auto t = *s.rbegin();
  if ((t.first >= 0 && t.second + mn >= 0) || (mn >= 0 && t.first + bal >= 0)) {
    s.erase(s.find(t));
    return 1;
  }
  return 0;
}
signed main() {
  ios::sync_with_stdio(0);
  cin.tie();
  cout.tie();
  long long n;
  cin >> n;
  for (long long i = 0; i < n; i++) {
    cin >> s[i];
    build(i);
  }
  long long ans = 0;
  for (long long i = 0; i < n; i++) {
    bool k = check(a[-bal[i]], mn[i], bal[i]);
    if (!k) {
      a[bal[i]].insert({mn[i], bal[i]});
    } else
      ans++;
  }
  cout << ans;
  return 0;
}
