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))
UyA9IGlucHV0KCkKTiA9IGxlbihTKQoKbWVtbyA9IHt9CgpkZWYgZ28obGFzdCxvKToKICAgICMgKmNvdW50KiBhbGwgKnZhbGlkKiBzdWZmaXhlcyBmb3IgdGhlIGN1cnJlbnQgc3Vic2VxdWVuY2UKICAgICMgYXNzdW1pbmcgdGhhdCBTW2xhc3RdIHdhcyB0aGUgbGFzdCBjaGFyYWN0ZXIgdXNlZAogICAgIyBhbmQgd2UgY3VycmVudGx5IGhhdmUgbyBvcGVuZWQgcGFyZW50aGVzZXMKCiAgICAjIGlmIHdlIGFscmVhZHkgc29sdmVkIHRoaXMsIHJlY2FsbCB0aGUgcmVzdWx0CiAgICBpZiAobGFzdCxvKSBpbiBtZW1vOiByZXR1cm4gbWVtb1sgKGxhc3QsbykgXQoKICAgICMgaWYgZXZlcnl0aGluZyBnb3QgY2xvc2VkLCB3ZSBjYW4gZW5kIHJpZ2h0IHdoZXJlIHdlIGFyZQogICAgaWYgbz09MDogYW5zd2VyID0gMQogICAgZWxzZTogICAgYW5zd2VyID0gMAoKICAgICMgd2UgY2FuIGFsd2F5cyB0cnkgYWRkaW5nIGFub3RoZXIgJygnCiAgICBuZXh0bCA9IGxhc3QrMQogICAgd2hpbGUgbmV4dGw8TiBhbmQgU1tuZXh0bF0gIT0gJygnOiBuZXh0bCArPSAxCiAgIC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