while 1: i=a=0 for c in input():i+=a*2<=i;a+=c>'(' print(i)