#include <bits/stdc++.h>
const long long LLINF = (1ll << 63) - 1;
const int INF = (1 << 31) - 1;
const long double PI = 3.141592653589793;
const long double EPS = 1e-15;
const unsigned long long MOD = (1e9) + 7;
const unsigned long long MOD2 = 998244353;
const int ENGLISH_ALPHABET_SIZE = 26;
const int N = 1e3 + 1;
const int M = 1e9 + 10;
using namespace std;
long long n;
string s;
map<long long, long long> open, closed;
long long ans = 0;
bool is_ok(const string &s) {
  int closed = 0;
  bool nc = false, no = false;
  for (auto c : s) {
    if (c == '(') {
      closed--;
    } else {
      closed++;
      if (closed > 0) {
        no = true;
        closed = 0;
      }
    }
  }
  if (closed < 0) nc = true;
  return !(nc && no);
}
void solve() {
  cin >> n;
  for (int i = 0, b = 0, zero = 0; i < n; ++i, b = 0) {
    cin >> s;
    if (!is_ok(s)) continue;
    for (auto c : s)
      if (c == ')')
        b--;
      else
        b++;
    if (b > 0) {
      if (closed[b] > 0) {
        closed[b]--;
        ans++;
      } else
        open[b]++;
    } else if (b < 0) {
      b = -b;
      if (open[b]) {
        open[b]--;
        ans++;
      } else
        closed[b]++;
    } else {
      if (zero) {
        zero--;
        ans++;
      } else
        zero++;
    }
  }
  cout << ans << endl;
}
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(nullptr);
  int t = 1;
  for (int i = 0; i < t; ++i) solve();
  return 0;
}
