#include <bits/stdc++.h>
using namespace std;
const double pi = acos(-1.0);
const int inf = 0x3f3f3f3f;
const long long INF = 0x3f3f3f3f3f3f3f3fll;
const int mod = 1e9 + 7;
const int N = 500010;
const int dir[][2] = {{-1, 0}, {0, -1}, {0, 1}, {1, 0}};
set<int> neg[N];
int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  ;
  int n;
  while (cin >> n) {
    string str;
    map<int, int> ma1, ma2;
    int zero = 0;
    vector<int> pos;
    for (int i = 0; i < n; ++i) {
      cin >> str;
      int Min = 1e9, Max = -1e9, all = 0;
      for (int j = 0; j < str.length(); ++j) {
        if (str[j] == '(')
          all += 1;
        else
          all -= 1;
        Min = min(Min, all);
        Max = max(Max, all);
      }
      if (all > 0 && Min >= 0)
        pos.push_back(all);
      else if (all < 0 && Min >= all)
        ma2[all]++;
      else if (all == 0 && Min >= 0)
        zero++;
    }
    int ans = zero / 2;
    for (auto x : pos)
      if (ma2[-x] > 0) {
        ans++;
        ma2[-x]--;
      }
    cout << ans << endl;
  }
  return 0;
}
