n=int(input()) S=input() if n&1: print('No') exit() a=0 for x in S: if x=='(': a+=1 else: a-=1 print(abs(a)>>1)