#include <bits/stdc++.h>
using namespace std;
int n;
map<int, int> mp[2];
char s[500010];
int main() {
  scanf("%d", &n);
  int cn = 0;
  for (int i = 0; i < n; i++) {
    scanf("%s", s);
    int j = 0, len = strlen(s), sign = 0, flag = 0, ind = 0;
    stack<char> st;
    while (j < len) {
      if (s[j] == '(')
        st.push('('), sign++;
      else {
        sign--;
        if (!st.empty())
          st.pop();
        else {
          ind++;
        }
      }
      j++;
    }
    if (ind > 0 && !st.empty()) continue;
    if (sign == 0) {
      cn++;
      continue;
    }
    mp[sign < 0][abs(sign)]++;
  }
  int ans = 0;
  for (const auto& it : mp[0]) ans += min(mp[1][it.first], it.second);
  printf("%d\n", ans + cn / 2);
  return 0;
}
