#include <bits/stdc++.h>
#pragma GCC optimize("Ofast")
#pragma GCC optimize("unroll-loops")
using namespace std;
const int maxn = 1e6 + 10, maxm = 2e6 + 10;
const int INF = 0x3f3f3f3f;
const int mod = 1e9 + 7;
const double PI = acos(-1.0);
int casn, n, m, k;
int num[maxn];
int main() {
  ios::sync_with_stdio(false);
  cin >> n;
  vector<string> s(n);
  map<int, int> x;
  for (auto& i : s) {
    cin >> i;
    int cnt = 0, flag = 0;
    int cnt2 = 0;
    for (auto j : i) {
      if (cnt2 == 0) {
        if (j == ')') {
          flag++;
          continue;
        }
        cnt2++;
        continue;
      }
      if (j == '(')
        cnt2++;
      else
        cnt2--;
    }
    if (cnt2 == 0) {
      cnt -= flag;
    } else {
      if (flag) continue;
      cnt = cnt2;
    }
    if (x[-cnt]) {
      x[-cnt]--;
      m++;
    } else
      x[cnt]++;
  }
  cout << m;
  return 0;
}
