#include <bits/stdc++.h>
using namespace std;
int n, ans(0);
string second[100005];
pair<int, int> p[100005];
vector<pair<int, int> > q1, q2;
void solve(string second, int x) {
  p[x].second = 500005;
  for (int i = 0; i < second.length(); i++) {
    if (second[i] == '(')
      ++p[x].first;
    else
      --p[x].first;
    p[x].second = min(p[x].second, p[x].first);
  }
}
int main() {
  ios_base::sync_with_stdio(0);
  cin >> n;
  for (int i = 1; i <= n; i++) {
    cin >> second[i];
    solve(second[i], i);
    if (p[i].first > 0 && p[i].second >= 0)
      q1.push_back(p[i]);
    else if (p[i].first < 0)
      q2.push_back(p[i]);
    else if (p[i].second >= 0)
      ++ans;
  }
  ans /= 2;
  int i = 0, j = q2.size() - 1;
  sort(q1.begin(), q1.end());
  sort(q2.begin(), q2.end());
  while (i < q1.size() && j >= 0) {
    if (q1[i].first + q2[j].first == 0 && q1[i].first + q2[j].second >= 0)
      ++ans, ++i, --j;
    else if (q1[i].first + q2[j].first < 0)
      ++i;
    else
      --j;
  }
  cout << ans;
  return 0;
}
