#include <bits/stdc++.h>
using namespace std;
const int INF = 2047483647;
const int mod = 1e9 + 7;
const long long int seed = 0xdefaced;
inline long long int rit() {
  long long int f = 0, key = 1;
  char c;
  do {
    c = getchar();
    if (c == '-') key = -1;
  } while (c < '0' || c > '9');
  do {
    f = f * 10 + c - '0';
    c = getchar();
  } while (c >= '0' && c <= '9');
  return f * key;
}
int check(int n, string s, int *ans) {
  int now = 0;
  for (int i = 0; i < n; i++) {
    if (s[i] == '(') {
      now++;
    } else {
      now--;
    }
    if (now < 0) {
      *ans = i;
      return now;
    }
  }
  return now;
}
int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  int n;
  vector<int> ve, ve2, ve3;
  cin >> n;
  for (int i = 0; i < n; i++) {
    string a;
    cin >> a;
    stack<char> st;
    for (int q = 0; q < a.size(); q++) {
      if (!st.empty() && st.top() == '(' && a[q] == ')') {
        st.pop();
      } else {
        st.push(a[q]);
      }
    }
    a.clear();
    while (!st.empty()) {
      a.push_back(st.top());
      st.pop();
    }
    int ty = 0, now = 0;
    for (int q = 0; q < a.size(); q++) {
      if (a[q] == '(') {
        if (ty == 0) ty = 1;
        now++;
      } else {
        if (ty == 0) ty = -1;
        now--;
      }
      if ((a[q] == '(' && ty == -1) || (a[q] == ')' && ty == 1)) {
        now = INF;
        break;
      }
    }
    if (now != INF) {
      if (now > 0) {
        ve.push_back(now);
      } else if (now < 0) {
        ve2.push_back(now);
      } else {
        ve3.push_back(now);
      }
    }
  }
  int ans = ve3.size() / 2;
  sort(ve.begin(), ve.end());
  sort(ve2.begin(), ve2.end(), greater<int>());
  for (int i = 0, q = 0; i < ve.size() && q < ve2.size(); i++) {
    while (ve[i] > abs(ve2[q])) {
      q++;
    }
    if (ve[i] + ve2[q] == 0) {
      q++;
      ans++;
    }
  }
  cout << ans << '\n';
  return 0;
}
