#include <bits/stdc++.h>
using namespace std;
using LL = long long;
const int mo = 1e9 + 7;
LL qpow(LL a, LL b) {
  LL ans = 1;
  a %= mo;
  while (b) {
    if (b & 1) ans = ans * a % mo;
    b >>= 1;
    ans = ans * a % mo;
  }
  return ans;
}
vector<int> a, b;
int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  int n;
  cin >> n;
  string s;
  int i, j;
  int c = 0;
  for (i = 0; i < n; i++) {
    cin >> s;
    int left = 0, right = 0;
    for (j = 0; j < s.length(); j++) {
      if (s[j] == '(')
        left++;
      else {
        if (left)
          left--;
        else
          right++;
      }
    }
    if (left == 0 && right)
      b.push_back(right);
    else if (left && right == 0)
      a.push_back(left);
    else if (left == 0 && right == 0)
      c++;
  }
  sort(a.begin(), a.end());
  sort(b.begin(), b.end());
  int l = 0, r = 0;
  LL ans = 0;
  while (l < a.size() && r < b.size()) {
    if (a[l] == b[r]) {
      ans++;
      l++, r++;
    } else if (a[l] < b[r])
      l++;
    else
      r++;
  }
  ans += (LL)c / 2;
  cout << ans << endl;
  return 0;
}
