#include <bits/stdc++.h>
using namespace std;
const long long oo = 1e18;
int dx[8] = {1, -1, 0, 0, 1, -1, 1, -1};
int dy[8] = {0, 0, 1, -1, 1, -1, -1, 1};
const int N = 102050;
const double PI = acos(-1);
int main() {
  int n;
  cin >> n;
  string x[n];
  vector<int> v1, v2;
  int u = 0;
  for (int i = 0; i < n; i++) {
    cin >> x[i];
    int sum = 0, mx = 0;
    for (int j = 0; j < x[i].size(); j++) {
      if (x[i][j] == '(') {
        sum++;
      } else {
        sum--;
        mx = min(mx, sum);
      }
    }
    if (mx >= 0) {
      if (sum == 0) {
        u++;
      } else
        v1.push_back(sum);
    } else {
      if (sum < 0 && sum == mx) v2.push_back(sum);
    }
  }
  long long ans = u / 2;
  sort(v1.begin(), v1.end());
  sort(v2.begin(), v2.end());
  int j = v2.size() - 1;
  int s = 0;
  for (int i = 0; i < v1.size(); i++) {
    s = 0;
    while (j >= 0 && v2[j] > (-1 * v1[i])) j--;
    if (j >= 0 && v2[j] == (-1 * v1[i])) {
      s++;
      j--;
    }
    ans += s;
  }
  cout << ans << endl;
  return 0;
}
