#include <bits/stdc++.h>
using namespace std;
template <class U, class T>
void Max(U &first, T second) {
  if (first < second) first = second;
}
template <class U, class T>
void Min(U &first, T second) {
  if (first > second) first = second;
}
template <class T>
void add(int &a, T b) {
  a = (a + b) % 1000000007;
}
inline int gcd(int a, int b) { return b == 0 ? a : gcd(b, a % b); }
inline long long gcd(long long a, long long b) {
  return b == 0 ? a : gcd(b, a % b);
}
int pow(int a, int b) {
  int ans = 1;
  while (b) {
    if (b & 1) ans = 1LL * ans * a % 1000000007;
    a = 1LL * a * a % 1000000007;
    b >>= 1;
  }
  return ans;
}
int pow(int a, int b, int c) {
  int ans = 1;
  while (b) {
    if (b & 1) ans = 1LL * ans * a % c;
    a = 1LL * a * a % c;
    b >>= 1;
  }
  return ans;
}
int L[500010], R[500010];
char s[500010];
int main() {
  int ca = 0, T, k, i, j, n, m = 0, K;
  double start = clock();
  scanf("%d", &n);
  int cnt = 0;
  for (int i = 0; i < n; i++) {
    scanf("%s", s);
    m = strlen(s);
    k = 0;
    K = 1;
    for (int j = 0; j < m; j++) {
      if (s[j] == '(')
        k++;
      else {
        if (k == 0) {
          K = 0;
          break;
        }
        k--;
      }
    }
    if (K) {
      if (k == 0)
        cnt++;
      else
        L[k]++;
    }
    k = 0;
    K = 1;
    for (int j = m - 1; j >= 0; j--) {
      if (s[j] == ')')
        k++;
      else {
        if (k == 0) {
          K = 0;
          break;
        }
        k--;
      }
    }
    if (K) {
      if (k) R[k]++;
    }
  }
  int ans = 0;
  for (int i = 1; i < 500010; i++) ans += min(L[i], R[i]);
  ans += cnt / 2;
  printf("%d\n", ans);
  cerr << (1. * clock() - start) / CLOCKS_PER_SEC << "\n";
}
