N = int(input()) S = [input() for i in range(N)] T = "" for i in range(N): T += S[i] maxeye = -1 eyen = -1 for i in range(1000): x = T.count("(" + "^" * i + ")") if x >= maxeye: maxeye = x eyen = i print(eyen)