#include <bits/stdc++.h>
using namespace std;
long long a[500005];
long long b[500005];
int main() {
  long long n, z = 0, k = 0, maxn = 0;
  string s;
  memset(a, 0, sizeof(a));
  memset(b, 0, sizeof(b));
  scanf("%lld", &n);
  for (long long int i = 1; i <= n; ++i) {
    cin >> s;
    long long num1 = 0, num2 = 0, num;
    for (long long int j = 0; j <= s.size() - 1; ++j) {
      if (s[j] == '(') num1++;
      if (s[j] == ')') {
        if (num1 != 0)
          num1--;
        else
          num2++;
      }
    }
    if (num1 == 0 && num2 != 0) {
      if (a[num2] != 0) {
        a[num2]--;
        z++;
      } else
        b[num2]++;
    }
    if (num1 != 0 && num2 == 0) {
      if (b[num1] != 0) {
        b[num1]--;
        z++;
      } else
        a[num1]++;
    }
    if (num1 == 0 && num2 == 0) k++;
  }
  if (k >= 2) z += k / 2;
  printf("%lld", z);
  return 0;
}
