#include <bits/stdc++.h>
using namespace std;
int32_t main() {
  long long n, i, j, k, l, t, s2 = 0;
  cin >> t;
  map<long long, long long> m1, m2;
  string s;
  while (t--) {
    cin >> s;
    n = s.size();
    stack<char> s1;
    s1.push(s[0]);
    for (i = 1; i < n; i++) {
      if (s1.empty())
        s1.push(s[i]);
      else {
        char ch = s1.top();
        if (ch == s[i])
          s1.push(s[i]);
        else {
          if (ch == '(' && s[i] == ')')
            s1.pop();
          else
            s1.push(s[i]);
        }
      }
    }
    if (s1.empty())
      s2++;
    else {
      long long a, b;
      a = b = 0;
      while (!s1.empty()) {
        char ch = s1.top();
        if (ch == '(')
          b++;
        else
          a++;
        s1.pop();
      }
      if (a > 0 && b > 0)
        ;
      else {
        if (a == 0)
          m2[b]++;
        else
          m1[a]++;
      }
    }
  }
  l = s2 / 2;
  for (auto it = m1.begin(); it != m1.end(); it++) {
    i = (it->first);
    j = m1[i];
    k = m2[i];
    l += min(j, k);
  }
  cout << l;
}
