def fun(s):
    count = 0
    for i in range(len(s)):
        if s[i] == '0':
            return count
        elif s[i] =='(':
            count += 1
        else:
            count -= 1