#include <bits/stdc++.h>
using namespace std;
vector<string> d;
vector<int> datospos, datosneg;
int main() {
  if (fopen("input.txt", "r")) freopen("input.txt", "r", stdin);
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  int n;
  cin >> n;
  d.assign(n, string());
  for (int i = 0; i < n; i++) cin >> d[i];
  int zeros = 0;
  for (int i = 0; i < n; i++) {
    int tam = d[i].length();
    int cur = 0;
    for (int j = 0; j < tam; j++) {
      if (d[i][j] == '(')
        cur++;
      else
        cur--;
    }
    if (cur > 0) {
      int pos = 0, aux = 0;
      for (int j = tam - 1; j >= 0; j--) {
        if (d[i][j] == '(')
          aux++;
        else
          aux--;
        pos = max(pos, aux);
      }
      if (pos <= cur) datospos.push_back(cur);
    } else if (cur < 0) {
      int neg = 0, aux = 0;
      for (int j = 0; j < tam; j++) {
        if (d[i][j] == '(')
          aux++;
        else
          aux--;
        neg = min(neg, aux);
      }
      if (-neg <= -cur) datosneg.push_back(-cur);
    } else {
      bool flag = 1;
      int aux = 0;
      for (int j = 0; j < tam; j++) {
        if (d[i][j] == '(')
          aux++;
        else
          aux--;
        if (aux < 0) flag = 0;
      }
      for (int j = tam - 1; j >= 0; j--) {
        if (d[i][j] == '(')
          aux++;
        else
          aux--;
        if (aux > 0) flag = 0;
      }
      if (flag) zeros++;
    }
  }
  sort(datospos.begin(), datospos.end());
  sort(datosneg.begin(), datosneg.end());
  int indpos = 0, indneg = 0, ans = 0;
  while (indpos < datospos.size() && indneg < datosneg.size()) {
    if (datospos[indpos] == datosneg[indneg]) {
      ans++;
      indpos++;
      indneg++;
    } else if (datospos[indpos] > datosneg[indneg]) {
      indneg++;
    } else
      indpos++;
  }
  printf("%d", ans + zeros / 2);
  return 0;
}
