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