N = int(input())

brackets = input()

counter = 0
for i in brackets:
    if i == "(":
        counter += 1

print(counter)
