#include <bits/stdc++.h>
using namespace std;
int main() {
  map<pair<int, int>, int> m;
  int n;
  cin >> n;
  int ans = 0;
  for (int i = 0; i < n; i++) {
    int a = 0;
    int b = 0;
    string s;
    cin >> s;
    for (auto j : s) {
      if (j == '(') a++;
      if (j == ')') {
        if (a == 0)
          b++;
        else
          a--;
      }
    }
    pair<int, int> p = make_pair(a, b);
    pair<int, int> pd = make_pair(b, a);
    if (b == 0) {
      if (m[make_pair(0, a)] != 0) {
        ans++;
        m[make_pair(0, a)]--;
      } else {
        m[make_pair(a, 0)]++;
      }
    } else if (a == 0) {
      if (m[make_pair(b, 0)] != 0) {
        ans++;
        m[make_pair(b, 0)]--;
      } else {
        m[make_pair(0, b)]++;
      }
    }
  }
  cout << ans;
  return 0;
}
