#include <bits/stdc++.h>
using namespace std;
const long long LLMAX = 2e18;
const int MOD = 1e9 + 7;
const int MAXN = 1e6 + 10;
template <class T>
inline void read(T &DataIn) {
  DataIn = 0;
  T Flag = 0;
  char c = getchar();
  while (!isdigit(c)) {
    Flag |= c == '-';
    c = getchar();
  }
  while (isdigit(c)) {
    DataIn = DataIn * 10 + c - '0';
    c = getchar();
  }
  DataIn = Flag ? -DataIn : DataIn;
}
template <class T>
inline void write(T DataOut, char EndChar = '\n') {
  T lenth = 0, number[30];
  if (DataOut == 0) {
    putchar(48);
    putchar(EndChar);
    return;
  }
  while (DataOut > 0) {
    number[++lenth] = DataOut % 10;
    DataOut /= 10;
  }
  for (int i = lenth; i >= 1; i--) putchar(number[i] + 48);
  putchar(EndChar);
}
priority_queue<int, vector<int>, less<int> > qd;
priority_queue<int, vector<int>, greater<int> > qu;
int all = 0;
struct node {
  string s;
  int val;
  bool operator<(const node &n) const { return val < n.val; }
} a[MAXN];
int main(void) {
  FILE *fin = NULL, *fout = NULL;
  ios::sync_with_stdio(false);
  cin.tie(0);
  int n, ans = 0;
  cin >> n;
  for (int i = 0; i < n; i++) {
    int cnt = 0;
    cin >> a[(++all)].s;
    a[all].val = 0;
    for (int j = 0; j < a[all].s.size(); j++)
      if (a[all].s[j] == '(')
        cnt++;
      else
        cnt--;
    if (cnt >= 0) {
      for (int j = 0; j < a[all].s.size(); j++) {
        if (a[all].s[j] == '(')
          a[all].val++;
        else
          a[all].val--;
        if (a[all].val < 0) {
          a[all].val = 0;
          all--;
          break;
        }
      }
    } else {
      reverse(a[all].s.begin(), a[all].s.end());
      for (int j = 0; j < a[all].s.size(); j++) {
        if (a[all].s[j] == ')')
          a[all].val--;
        else
          a[all].val++;
        if (a[all].val > 0) {
          a[all].val = 0;
          all--;
          break;
        }
      }
    }
  }
  sort(a + 1, a + all + 1);
  for (int i = 1, j = all; i < j; i++) {
    while (i < j && a[i].val + a[j].val > 0) j--;
    if (i < j && a[i].val + a[j].val == 0) {
      ans++;
      j--;
    }
  }
  cout << ans << endl;
  return 0;
}
