#include <bits/stdc++.h>
using namespace std;
int dx8[] = {0, 0, 1, 1, 1, -1, -1, -1};
int dy8[] = {1, -1, 1, -1, 0, 0, -1, 1};
const double PI = acos(-1.0);
const double EPS = 1e-6;
const int MOD = (int)1e9 + 7;
const int maxn = (int)5e5 + 5;
const int LOGN = 20;
int lft[maxn], rgt[maxn];
int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(NULL);
  cout.tie(NULL);
  int n;
  while (cin >> n) {
    int corr = 0;
    string s;
    for (int i = 1; i <= (n); i++) {
      cin >> s;
      int c = 0;
      int ln = s.length();
      bool ok = 1;
      for (int j = 0; j < (ln); j++) {
        if (s[j] == '(')
          c++;
        else
          c--;
        if (c < 0) {
          ok = 0;
          break;
        }
      }
      if (c == 0) {
        corr++;
        continue;
      }
      if (ok && c > 0) {
        lft[c]++;
        continue;
      }
      c = 0;
      ok = 1;
      for (int j = (ln - 1); j >= (0); j--) {
        if (s[j] == ')')
          c++;
        else
          c--;
        if (c < 0) {
          ok = 0;
          break;
        }
      }
      if (ok && c > 0) rgt[c]++;
    }
    long long ans = corr / 2;
    for (int i = 1; i <= (5e5); i++) ans += min(lft[i], rgt[i]);
    cout << ans << "\n";
  }
  return 0;
}
