#include <bits/stdc++.h>
using namespace std;
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
  map<int, int> unaccounted_opens, unaccounted_ends;
  int ans = 0;
  int T;
  cin >> T;
  for (int i = 0; i < T; ++i) {
    string s;
    cin >> s;
    int open = 0, end = 0;
    for (char j : s) {
      if (j == '(')
        open++;
      else {
        if (open > 0)
          open--;
        else
          end++;
      }
    }
    if (open == 0 && end == 0) ans++;
    if (open == 0 || end == 0) {
      if (open > 0)
        unaccounted_opens[open]++;
      else
        unaccounted_ends[end]++;
    }
  }
  int ans2 = 0;
  for (auto x : unaccounted_opens) {
    ans2 += min(x.second, unaccounted_ends[x.first]);
  }
  cout << ans / 2 + ans2 << "\n";
}
