#include void main(){char s[256];while (fgets(s, 256, stdin)){int p=0,a=0;for (;p<256;p++){a+=s[p]=='('?1 :-1;if (a==-1)break;}printf("%d\n", ++p);}}