input()
z = input()

out = 0
for a in z:
    if a == ')':
        out += 1

print(out)