a[4000][4000];*p=a[1],*q=a;M=4e3,s;main(t){for(gets(&t);t=~getchar();~t&1?s<(q[M]=((t=q[M-1])