main=interact$((++" ")=<<).map f.lines;f x=show$g 0 0 x;g _ n[]=n;g 0n(x:p)|x=='|'=g 0(n+1)p|0<1=g 1 n p;g 1n(x:p)|x=='|'=g 0(n+1)p|0<1=n