#include <bits/stdc++.h>
using namespace std;
const int mod = 1e9 + 7;
const int MAX = 1e6 + 5;
const int INF = 0x3f3f3f3f;
const double eps = 1e-8;
int dir[9][2] = {0, 1, 0, -1, 1, 0, -1, 0, -1, -1, -1, 1, 1, -1, 1, 1};
template <class T>
bool gmax(T &a, T b) {
  return a < b ? a = b, 1 : 0;
}
template <class T>
bool gmin(T &a, T b) {
  return a > b ? a = b, 1 : 0;
}
template <class T>
void gmod(T &a, T b) {
  a = ((a + b) % mod + mod) % mod;
}
long long gcd(long long a, long long b) {
  while (b) b ^= a ^= b ^= a %= b;
  return a;
}
long long inv(long long b) {
  return b == 1 ? 1 : (mod - mod / b) * inv(mod % b) % mod;
}
long long qpow(long long n, long long m) {
  n %= mod;
  long long ans = 1;
  for (; m; m >>= 1) {
    if (m & 1) ans = ans * n % mod;
    n = n * n % mod;
  }
  return ans;
}
struct node {
  int t, next;
  long long len;
} edge[MAX << 1];
int head[MAX], cnt;
void initedge(int n) {
  memset(head, -1, sizeof(head[0]) * (n + 1));
  cnt = 0;
}
void addedge(int u, int v, long long len = 0) {
  edge[cnt] = node{v, head[u], len};
  head[u] = cnt++;
}
int n;
char str[MAX << 1];
char *p[MAX];
int a[MAX];
int ok[MAX];
int main() {
  while (cin >> n) {
    char *now = str;
    for (int i = 1; i <= n; i++) {
      scanf("%s", now);
      p[i] = now;
      now += strlen(now) + 1;
    }
    int tag = 0;
    for (int i = 1; i <= n; i++) {
      int top = 0;
      for (int j = 0; p[i][j]; j++) {
        if (p[i][j] == '(')
          str[top++] = '(';
        else if (str[top - 1] == '(')
          top--;
        else
          str[top++] = ')';
      }
      if (top == 0)
        ok[++tag] = 0;
      else if (str[top - 1] == str[0]) {
        if (str[0] == '(')
          ok[++tag] = -top;
        else
          ok[++tag] = top;
      }
    }
    map<int, int> M;
    for (int i = 1; i <= tag; i++) {
      M[ok[i]]++;
    }
    long long ans = 0;
    for (int i = 1; i <= tag; i++) {
      if (ok[i] < 0 && M[-ok[i]] > 0) {
        ans++;
        M[-ok[i]]--;
      }
    }
    ans += M[0] / 2;
    cout << ans << endl;
  }
}
