#include <bits/stdc++.h>
using namespace std;
long long po(long long a, long long b) {
  long long x = 1, y = a;
  while (b > 0) {
    if (b % 2) {
      x = x * y;
      x %= 1000000007;
    }
    y = y * y;
    y %= 1000000007;
    b /= 2;
  }
  return x;
}
int main() {
  if (0) {
    freopen("/Users/mohibmanva/Desktop", "r", stdin);
    freopen("/Users/mohibmanva/Desktop", "w", stdout);
  }
  int T = 1;
  while (T--) {
    int n;
    scanf("%d", &n);
    static char str[500005];
    static int dp1[500005], dp2[500005];
    for (int i = 0; i < n; i++) {
      scanf("%s", &str);
      int len = strlen(str);
      bool neg = false;
      int rem = 0;
      int o = 0;
      for (int j = 0; j < len; j++) {
        if (str[j] == '(') {
          o++;
        } else {
          if (o == 0) {
            neg = true;
            rem++;
          } else {
            o--;
          }
        }
      }
      if (neg && o > 0) {
      } else {
        if (neg) {
          dp1[rem]++;
        } else {
          dp2[o]++;
        }
      }
    }
    int ans = 0;
    for (int i = 1; i <= 500005; i++) {
      ans += min(dp1[i], dp2[i]);
    }
    ans += dp2[0] / 2;
    printf("%d\n", ans);
  }
  return 0;
}
