#include <bits/stdc++.h>
using namespace std;
void io() {}
long long arr[200005];
long long brr[200005];
map<long long, long long> mp;
vector<long long> adj[1000001];
long long vis[1000001];
long long n, m, k, l, t;
long long ans = 0, cnt = 1, tmp = 1, sum;
bool check(string s, int a) {
  string tmp;
  if (a < 0) {
    while (a++) {
      tmp += "(";
    }
    s = tmp + s;
  }
  if (a > 0) {
    while (a--) {
      tmp += ")";
    }
    s = s + tmp;
  }
  stack<char> st;
  for (int i = 0; i < int(s.size()); ++i) {
    if (s[i] == '(') {
      st.push(s[i]);
    } else if (s[i] == ')') {
      if (st.empty()) {
        return false;
      } else {
        st.pop();
      }
    }
  }
  return true;
}
int main() {
  io();
  ios ::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
  cin >> n;
  int arr[n];
  int mn = 1e8;
  for (int i = 0; i < int(n); ++i) {
    string s;
    cin >> s;
    arr[i] = 0;
    for (int j = 0; j < int(s.size()); ++j) {
      if (s[j] == '(')
        arr[i]++;
      else
        arr[i]--;
    }
    if (!check(s, arr[i])) {
      arr[i] = 1e8;
    }
    mn = min(mn, arr[i]);
  }
  for (int i = 0; i < int(n); ++i) {
    mp[arr[i]]++;
  }
  for (int i = mn; i < 0; i++) {
    ans += min(mp[i], mp[-i]);
  }
  ans += mp[0] / 2;
  cout << ans << '\n';
}
