One day, Yuhao came across a problem about checking if some bracket sequences are correct bracket sequences.

A bracket sequence is any non-empty sequence of opening and closing parentheses. A bracket sequence is called a correct bracket sequence if it's possible to obtain a correct arithmetic expression by inserting characters "+" and "1" into this sequence. For example, the sequences "(())()", "()" and "(()(()))" are correct, while the bracket sequences ")(", "(()" and "(()))(" are not correct.

Yuhao found this problem too simple for him so he decided to make the problem harder. You are given many (not necessarily correct) bracket sequences. The task is to connect some of them into ordered pairs so that each bracket sequence occurs in at most one pair and the concatenation of the bracket sequences in each pair is a correct bracket sequence. The goal is to create as many pairs as possible.

This problem unfortunately turned out to be too difficult for Yuhao. Can you help him and solve it?

Input

The first line contains one integer n (1 ≤ n ≤ 10^5) — the number of bracket sequences.

Each of the following n lines contains one bracket sequence — a non-empty string which consists only of characters "(" and ")".

The sum of lengths of all bracket sequences in the input is at most 5 ⋅ 10^5.

Note that a bracket sequence may appear in the input multiple times. In this case, you can use each copy of the sequence separately. Also note that the order in which strings appear in the input doesn't matter.

Output

Print a single integer — the maximum number of pairs which can be made, adhering to the conditions in the statement.

Examples

Input


7
)())
)
((
((
(
)
)


Output


2


Input


4
(
((
(((
(())


Output


0


Input


2
(())
()


Output


1

Note

In the first example, it's optimal to construct two pairs: "(( )())" and "( )".
import sys
aList = []
bList = []
correctSeq = 0
finalAns = 0
def giveValues(readInput):
    global aList
    global bList
    global correctSeq
    #Find the "value" of the input by the number of parenthesis
    leftBraNeeded = 0
    rightBraNeeded = 0
    for x in readInput:
        if x == "(":
            rightBraNeeded += 1
        else:
            #Check if there is any right bracket needed
            #If so, remove 1
            if rightBraNeeded > 0:
                rightBraNeeded -= 1
            else:
            #If not, we need 1 more left bracket
                leftBraNeeded += 1
    #if left bracket and right bracket needed aren't 0, 
    #we can move on to the next input and ignore this sequence
    if leftBraNeeded > 0 and rightBraNeeded > 0:
        return
    #if left bracket needed == right bracket needed == 0, 
    #this is a correct bracket sequence. we just need to remember how many there are.
    if leftBraNeeded == 0 and rightBraNeeded == 0:
        correctSeq += 1
        return
    #if left bracket needed > 0 and right bracket needed == 0, 
    #we record it in aList. Otherwise we record it in bList. 
    if leftBraNeeded > 0:
        aList.append(leftBraNeeded)
        return
    else:
        bList.append(rightBraNeeded)
        return
    
numInput = int(sys.stdin.readline().strip())
for x in range(numInput):
    giveValues(sys.stdin.readline().strip())

#print("a: ")
#print(aList)
#print("b: ")
#print(bList)
#print("Correct: " + str(correctSeq))
#Step 2:
#Matching the brackets where the values of a == the values of b
for x in aList:
    for y in bList:
        if x == y:
            #Remove the value in y and move on
            finalAns += 1
            bList.remove(y)
            break
#Don't forget the correct bracket sequence we initially have
finalAns += int(correctSeq / 2)
#print("a: ")
#print(aList)
#print("b: ")
#print(bList)
#print("Correct: " + str(correctSeq))
#print("final Answer: " + str(finalAns))
print(str(finalAns))