#include <bits/stdc++.h>
using namespace std;
int arr[100001];
char temp[500001];
int pointer = 0;
int ans = 0;
int main() {
  int n;
  char c;
  scanf("%d", &n);
  getchar();
  for (int i = 0; i < n; i++) {
    int pt = 0;
    while (1) {
      scanf("%c", &c);
      if (c == '\n')
        break;
      else if (pt > 0) {
        if (c == ')' && temp[pt - 1] == '(') {
          temp[pt - 1] = NULL;
          pt--;
        } else {
          temp[pt] = c;
          pt++;
        }
      } else {
        temp[pt] = c;
        pt++;
      }
    }
    if (pt == 0) {
      arr[pointer] = 0;
      pointer++;
    } else if (temp[pt - 1] == temp[0]) {
      if (temp[0] == '(')
        arr[pointer] = pt;
      else
        arr[pointer] = -1 * pt;
      pointer++;
    }
  }
  if (pointer <= 1) {
    printf("0");
    return 0;
  }
  sort(arr, arr + pointer);
  int pt1 = 0, pt2 = pointer - 1;
  while (pt2 > pt1) {
    if (arr[pt2] + arr[pt1] < 0)
      pt1++;
    else if (arr[pt2] + arr[pt1] > 0)
      pt2--;
    else {
      ans++;
      pt1++;
      pt2--;
    }
  }
  printf("%d", ans);
}
