import queue

nob = int(input())
bra = input()

i = 0

def f ():
    global i, bra
    tmp = 0
    while True:
        if bra[i] == "(":
            if tmp == 0:
                i += 1
                tmp = f()
                if i == nob:
                    return tmp
            else:
                i += 1
                tmp *= f()
                if i == nob:
                    return tmp
        if bra[i] == ")":
            i += 1
            return tmp + 1



print(f())

