#include <bits/stdc++.h>
struct BracketSequence {
  int32_t index;
  int32_t total_balance;
  int32_t min_balance;
  BracketSequence() {}
  BracketSequence(int32_t index_, int32_t total_balance_,
                  int32_t min_balance_) {
    index = index_;
    total_balance = total_balance_;
    min_balance = min_balance_;
  }
  bool operator<(const BracketSequence& other) const {
    if (total_balance != other.total_balance)
      return total_balance < other.total_balance;
    if (min_balance != other.min_balance)
      return min_balance > other.min_balance;
    return index < other.index;
  }
  bool operator==(const BracketSequence& other) const {
    return index == other.index;
  }
};
int main() {
  int32_t num_sequences;
  std::cin >> num_sequences;
  int32_t num_zeroes = 0;
  std::vector<BracketSequence> sequences;
  for (int32_t i = 0; i < num_sequences; i++) {
    std::string sequence;
    std::cin >> sequence;
    int32_t min_balance = 0;
    int32_t balance = 0;
    for (int32_t j = 0; j < sequence.size(); j++) {
      if (sequence[j] == '(')
        balance++;
      else
        balance--;
      min_balance = std::min(min_balance, balance);
    }
    if (balance == 0) {
      if (min_balance == 0) num_zeroes++;
      continue;
    }
    sequences.emplace_back(i, balance, min_balance);
  }
  std::sort(sequences.begin(), sequences.end());
  std::set<BracketSequence> available_seconds;
  for (int32_t i = 0; i < sequences.size(); i++)
    if (sequences[i].total_balance < 0) available_seconds.insert(sequences[i]);
  int32_t answer = num_zeroes / 2;
  for (int32_t i = 0; i < sequences.size(); i++) {
    if (sequences[i].total_balance > 0) {
      if (sequences[i].min_balance >= 0) {
        int32_t other_balance = -sequences[i].total_balance;
        auto it = available_seconds.lower_bound({-1, other_balance, 1000000});
        if (it == available_seconds.end()) continue;
        if (it->index == sequences[i].index) it++;
        if (it == available_seconds.end()) continue;
        if (it->total_balance == other_balance &&
            sequences[i].total_balance + it->min_balance >= 0) {
          answer++;
          available_seconds.erase(it);
        }
      }
    }
  }
  std::cout << answer;
  return 0;
}
