a,b,t,m;main(i){for(;read(0,&t,1);i++)a=t-99?t==119?b&&!m|m>i-b+2?m=i-b+2:0,b=a:a:i;printf("%d",m-1);}