#include <bits/stdc++.h>
using namespace std;
char s[500005];
int A[500005][2];
int B[500005];
int C[500005];
int main() {
  ios::sync_with_stdio(false);
  int n;
  memset(A, 0, sizeof(A));
  memset(B, 0, sizeof(B));
  memset(C, 0, sizeof(C));
  cin >> n;
  for (int i = 0; i < n; i++) {
    cin >> s;
    int len = strlen(s);
    if (s[0] == ')' && s[len - 1] == '(') continue;
    for (int j = 0; j < len; j++) {
      if (s[j] == '(')
        A[i][0]++;
      else if (s[j] == ')' && A[i][0] > 0)
        A[i][0]--;
      else
        A[i][1]--;
    }
    if (A[i][0] >= 0 && A[i][1] == 0) C[i] = A[i][0];
    if (A[i][0] == 0 && A[i][1] <= 0) C[i] = A[i][1];
    if (C[i] >= 0 && (A[i][0] == 0 || A[i][1] == 0)) B[C[i]]++;
  }
  int ans = 0;
  for (int i = 0; i < n; i++) {
    if (C[i] < 0) {
      int t = 0 - C[i];
      if (B[t] > 0) {
        ans++;
        B[t]--;
      }
    }
  }
  ans += B[0] / 2;
  cout << ans << endl;
  return 0;
}
