#include <bits/stdc++.h>
using namespace std;
void print(vector<string> v) {
  for (auto x : v) cout << x << " ";
  puts("");
}
string create(string s) {
  stack<char> pilha;
  for (int i = 0; i < s.size(); i++) {
    if (s[i] == '(')
      pilha.push(s[i]);
    else {
      if (pilha.empty())
        pilha.push(s[i]);
      else if (pilha.top() == '(')
        pilha.pop();
      else
        pilha.push(s[i]);
    }
  }
  string ret;
  while (!pilha.empty()) ret += pilha.top(), pilha.pop();
  reverse(ret.begin(), ret.end());
  return ret;
}
string inverte(string s) {
  string aux = "";
  for (auto x : s) {
    if (x == ')')
      aux += '(';
    else
      aux += ')';
  }
  return aux;
}
int main() {
  int n;
  cin >> n;
  vector<string> v(n);
  vector<string> aux(n);
  map<string, int> mp;
  for (int i = 0; i < n; i++) {
    cin >> v[i];
    aux[i] = create(v[i]);
    mp[aux[i]]++;
  }
  int ans = 0;
  for (int i = 0; i < n; i++) {
    if (!mp[aux[i]]) continue;
    string inverso = inverte(aux[i]);
    if (mp[inverso]) {
      if (inverso == aux[i] and mp[inverso] == 1) continue;
      ans++;
      mp[inverso]--;
      mp[aux[i]]--;
    }
  }
  cout << ans << endl;
  return 0;
}
