#include <bits/stdc++.h>
using namespace std;
const int maxn = 1e6;
string b[maxn];
int p[maxn], n[maxn];
void get_id(string);
bool is_legal(string);
int main() {
  int N;
  scanf("%d", &N);
  memset(p, 0, sizeof(p));
  memset(n, 0, sizeof(n));
  for (int i = 0; i < N; i++) {
    cin >> b[i];
    get_id(b[i]);
  }
  int ans = 0;
  ans += (p[0] / 2);
  for (int i = 1; i < maxn; i++) {
    ans += min(p[i], n[i]);
  }
  printf("%d\n", ans);
  return 0;
}
void get_id(string c) {
  if (is_legal(c)) {
    p[0]++;
    return;
  }
  int len = c.size();
  int count = 0;
  bool find = false;
  for (int i = 0; i < len; i++) {
    if (c[i] == '(')
      count++;
    else
      count--;
    if (count < 0) find = true;
  }
  if (count > 0 && !find) p[count]++;
  find = false;
  count = 0;
  for (int i = len - 1; i >= 0; i--) {
    if (c[i] == ')')
      count++;
    else
      count--;
    if (count < 0) find = true;
  }
  if (count > 0 && !find) n[count]++;
}
bool is_legal(string c) {
  int len = c.size();
  int count = 0;
  for (int i = 0; i < len; i++) {
    if (c[i] == '(')
      count++;
    else
      count--;
    if (count < 0) return false;
  }
  if (!count)
    return true;
  else
    return false;
}
