a[1<<24];*p=a,*q;M=4e3,s;main(t){for(;t=~getchar();q++)t+36?t&4?q=p+=M:0:(s=fmax(s,q[M+1]=fmin(fmin(*q,q[1]),q[M])+1));s=!printf("%d",-~s/2);}