#include <bits/stdc++.h>
using namespace std;
const int N = 100100;
int main() {
  ios_base::sync_with_stdio(false);
  int n;
  cin >> n;
  int ans = 0;
  multiset<int> m;
  for (int i = 1; i <= n; i++) {
    string s;
    string str;
    cin >> s;
    for (auto c : s) {
      if (c == '(' || str.empty())
        str += c;
      else {
        if (str.back() == '(')
          str.pop_back();
        else
          str.push_back(')');
      }
    }
    if (!str.empty() && str[0] != str.back()) continue;
    int balance = str.size();
    if (str[0] == ')') balance = -balance;
    if (m.count(-balance)) {
      m.erase(m.find(-balance));
      ans++;
    } else {
      m.insert(balance);
    }
  }
  cout << ans << endl;
  return 0;
}
