#include <bits/stdc++.h>
using namespace std;
int n, a[20], nn;
int available[500005 * 2];
char seq[500005], c;
int main(int argc, char const *argv[]) {
  memset(available, 0, 500005 * 8);
  int n, tot = 0, count, c, pos = 0, counter, len;
  bool valid, frontMiss, backMiss;
  cin >> n;
  while (n--) {
    count = 0;
    cin >> seq;
    pos = 0;
    frontMiss = backMiss = false;
    counter = 0;
    while (1) {
      c = seq[pos++];
      if (c == '(') {
        count++;
        counter++;
      } else if (c == ')') {
        count--;
        if (counter) counter--;
      } else
        break;
      if (count < 0) frontMiss = true;
    }
    if (counter > 0) backMiss = true;
    if (backMiss && frontMiss) continue;
    if (available[(-1 * count) + 500005]) {
      tot++;
      available[(-1 * count) + 500005]--;
    } else {
      available[count + 500005]++;
    }
  }
  cout << tot << endl;
  return 0;
}
