import sys
s = sys.stdin.read()[:-1]
f = 0
for i,c in enumerate(s):
f += -1 if c == ')' else 1
if f == -1:
print(i+1)
break