#include <bits/stdc++.h>
using namespace std;
long long mypow(long long a, long long b) {
  if (b == 0) return 1;
  long long temp = mypow(a, b / 2);
  temp = (temp * temp) % 1000000007LL;
  if (b % 2 == 1) temp = (a * temp) % 1000000007LL;
  return temp;
}
int mygcd(int a, int b) {
  if (b == 0) return a;
  return mygcd(b, a % b);
}
int cntBits(long long a) {
  int ret = 0;
  while (a > 0) {
    ret++;
    a /= 2;
  }
  return ret;
}
map<pair<int, int>, int> m;
vector<pair<int, int> > v;
void func(string s) {
  int op = 0, cl = 0;
  for (int i = 0; i < s.size(); i++) {
    if (s[i] == '(')
      op++;
    else {
      if (op == 0)
        cl++;
      else
        op--;
    }
  }
  v.push_back(make_pair(op, cl));
  m[make_pair(op, cl)]++;
}
int main() {
  ios::sync_with_stdio(0);
  int tt = 1;
  for (int tcase = 1; tcase <= tt; tcase++) {
    int n, ans = 0;
    cin >> n;
    for (int i = 0; i < n; i++) {
      string s;
      cin >> s;
      func(s);
    }
    for (auto p : m) {
      if (p.first.second != 0) continue;
      if (p.first == make_pair(p.first.second, p.first.first)) {
        ans += (p.second / 2);
        m[p.first] = 0;
      } else {
        int val = min(p.second, m[make_pair(p.first.second, p.first.first)]);
        ans += val;
        m[p.first] -= val;
        m[make_pair(p.first.second, p.first.first)] -= val;
      }
    }
    cout << ans << "\n";
  }
  return 0;
}
