S = input()
N = len(S)

memo = {}

def go(last,o):
    # *count* all *valid* suffixes for the current subsequence
    # assuming that S[last] was the last character used
    # and we currently have o opened parentheses

    # if we already solved this, recall the result
    if (last,o) in memo: return memo[ (last,o) ]

    # if everything got closed, we can end right where we are
    if o==0: answer = 1
    else:    answer = 0

    # we can always try adding another '('
    nextl = last+1
    while nextl<N and S[nextl] != '(': nextl += 1
    if nextl<N: answer += go(nextl,o+1)

    # only if o>0, we can also try adding another ')'
    if o>0:
        nextr = last+1
        while nextr<N and S[nextr] != ')': nextr += 1
        if nextr<N: answer += go(nextr,o-1)

    # and that's it -- but don't forget to remember :)
    memo[ (last,o) ] = answer
    return answer

print(go(-1,0))