#include <bits/stdc++.h>
using namespace std;
void io() {}
long long arr[200005];
long long brr[200005];
long long val[200005];
long long siz[200005];
map<long long, long long> mp;
vector<pair<long long, long long> > edge[50005];
long long dist[5005][5005];
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;
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]--;
    }
    int cnt_open = 0, cnt_close = 0;
    int bal = 0;
    for (int j = 0; j < int(s.size()); ++j) {
      cnt_open += (s[j] == '(');
      cnt_close += (s[j] == ')');
    }
    for (int j = 0; j < s.size(); j++) {
      if (s[j] == '(')
        bal++;
      else {
        if (bal > 0) {
          cnt_open--;
          cnt_close--;
          bal--;
        }
      }
    }
    if (cnt_open > 0 && cnt_close > 0) 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';
}
