import std.stdio, std.string, std.conv;
import std.range, std.algorithm, std.array, std.typecons, std.container;
import std.math, std.numeric, core.bitop;



void main() {
    int n;
    scan(n);

    auto b = iota(n).map!(i => readln.chomp).array;

    int checkLeft(string s) {
        int h;

        foreach (ch ; s) {
            if (ch == '(') {
                h++;
            }
            else {
                h--;

                if (h < 0) {
                    return -1;
                }
            }
        }

        return h;
    }

    int checkRight(string s) {
        int h;

        foreach_reverse (ch ; s) {
            if (ch == ')') {
                h++;
            }
            else {
                h--;

                if (h < 0) {
                    return -1;
                }
            }
        }

        return h;
    }

    auto cnt = new int[](5 * 10^^5 + 1);
    int perfect;

    foreach (s ; b) {
        int h = checkLeft(s);
        if (h > 0) {
            cnt[h]++;
        }
        if (h == 0) {
            perfect++;
        }
    }

    int ans;

    foreach (s ; b) {
        int h = checkRight(s);
        if (h > 0 && cnt[h] > 0) {
            ans++;
            cnt[h]--;
        }
    }

    ans += perfect / 2;
    
    writeln(ans);
}



























void scan(T...)(ref T args) {
    import std.stdio : readln;
    import std.algorithm : splitter;
    import std.conv : to;
    import std.range.primitives;

    auto line = readln().splitter();
    foreach (ref arg; args) {
        arg = line.front.to!(typeof(arg));
        line.popFront();
    }
    assert(line.empty);
}


void fillAll(R, T)(ref R arr, T value) {
    static if (is(typeof(arr[] = value))) {
        arr[] = value;
    }
    else {
        foreach (ref e; arr) {
            fillAll(e, value);
        }
    }
}