#include <bits/stdc++.h>
using namespace std;
namespace Base {
const int inf = 0x3f3f3f3f, INF = 0x7fffffff;
const long long infll = 0x3f3f3f3f3f3f3f3fll, INFll = 0x7fffffffffffffffll;
template <typename T>
void read(T &x) {
  x = 0;
  int fh = 1;
  double num = 1.0;
  char ch = getchar();
  while (!isdigit(ch)) {
    if (ch == '-') fh = -1;
    ch = getchar();
  }
  while (isdigit(ch)) {
    x = x * 10 + ch - '0';
    ch = getchar();
  }
  if (ch == '.') {
    ch = getchar();
    while (isdigit(ch)) {
      num /= 10;
      x = x + num * (ch - '0');
      ch = getchar();
    }
  }
  x = x * fh;
}
template <typename T>
void chmax(T &x, T y) {
  x = x < y ? y : x;
}
template <typename T>
void chmin(T &x, T y) {
  x = x > y ? y : x;
}
}  // namespace Base
using namespace Base;
int n, numl[1000100], d, ans, numr[1000100];
char s[1000100];
int main() {
  read(n);
  for (int i = 1; i <= n; i++) {
    scanf("\n%s", s + 1);
    int len = strlen(s + 1), tmp = 0;
    for (int j = 1; j <= len; j++) {
      if (s[j] == '(')
        tmp++;
      else
        tmp--;
      if (tmp < 0) break;
    }
    if (tmp > 0) numl[tmp]++;
    tmp = 0;
    for (int j = len; j >= 1; j--) {
      if (s[j] == ')')
        tmp++;
      else
        tmp--;
      if (tmp < 0) break;
    }
    if (tmp > 0) numr[tmp]++;
    if (tmp == 0) d++;
  }
  for (int i = 1; i <= 1000000; i++) ans += min(numl[i], numr[i]);
  printf("%d\n", ans + d / 2);
  return 0;
}
