#include <bits/stdc++.h>
using namespace std;
const int MAXN = 200005;
const int INF = 1e9;
const long long MOD = 998244353;
int ans = 0, n;
map<int, int> cnt;
int check(const string &s) {
  int num;
  bool ok;
  num = 0;
  for (int i = 0; i < s.size(); i++) {
    char c = s[i];
    if (c == '(')
      num++;
    else
      num--;
    if (num < 0) break;
  }
  if (num >= 0) return num;
  num = 0;
  for (int i = s.size() - 1; i >= 0; i--) {
    char c = s[i];
    if (c == ')')
      num++;
    else
      num--;
    if (num < 0) break;
  }
  if (num >= 0) return -num;
  return INF;
}
int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  string s;
  cin >> n;
  for (int i = 0; i < n; i++) {
    cin >> s;
    int x = check(s);
    if (x == INF) continue;
    if (cnt[-x] > 0) {
      cnt[-x]--;
      ans++;
    } else {
      cnt[x]++;
    }
  }
  cout << ans << "\n";
}
