#include <bits/stdc++.h>
using namespace std;
const long long mxN = 1e5 + 5;
const long long INF = 1e18;
const long long mod = 1e9 + 7;
signed main() {
  long long n;
  cin >> n;
  vector<string> v(n);
  for (long long i = 0; i < n; i++) {
    cin >> v[i];
  }
  map<long long, long long> o, c;
  long long per = 0;
  for (long long i = 0; i < n; i++) {
    string s = v[i];
    stack<long long> st;
    for (auto x : s) {
      if (st.empty()) {
        st.push(x);
      } else {
        if (x == ')') {
          if (st.top() == '(')
            st.pop();
          else
            st.push(x);
        } else
          st.push(x);
      }
    }
    if (st.empty())
      per++;
    else {
      long long open = 0, closing = 0;
      while (!st.empty()) {
        if (st.top() == ')')
          open++;
        else
          closing++;
        st.pop();
      }
      if (open == 0) {
        c[closing]++;
      }
      if (closing == 0) {
        o[open]++;
      }
    }
  }
  long long ans = per / 2;
  for (auto x : o) {
    ans += min(x.second, c[x.first]);
  }
  cout << ans;
}
