a = input()
alist = []
i = 0
for b in a:
    if b == '(':
        i += 1
    else:
        alist.append(i)
        i -= 1
print(max(alist))