#include <bits/stdc++.h>
using namespace std;
int open[100000], close[100000];
stack<char> st;
int main() {
  int n, a, b, l1 = 0, l2 = 0, Count = 0, sum = 0;
  string s;
  scanf("%d", &n);
  for (int i = 1; i <= n; i++) {
    cin >> s;
    a = 0, b = 0;
    st.push(s[0]);
    for (int i = 1; i < s.length(); i++) {
      if (!st.empty()) {
        if (st.top() == '(' && s[i] == ')') {
          st.pop();
        } else {
          st.push(s[i]);
        }
      } else {
        st.push(s[i]);
      }
    }
    while (!st.empty()) {
      if (st.top() == '(') {
        a++;
      } else {
        b++;
      }
      st.pop();
    }
    if (a != 0 && b != 0) {
      continue;
    } else if (a == 0 && b == 0) {
      sum++;
    } else {
      if (a != 0) {
        l1++;
        open[l1] = a;
      } else {
        l2++;
        close[l2] = b;
      }
    }
  }
  sort(open + 1, open + l1 + 1);
  sort(close + 1, close + l2 + 1);
  Count = sum / 2;
  for (int i = 1, j = 1; i <= l1 && j <= l2;) {
    if (open[i] == close[j]) {
      Count++;
      i++, j++;
    } else if (open[i] < close[j]) {
      i++;
    } else {
      j++;
    }
  }
  printf("%d", Count);
  return 0;
}
