s=gets.chomp.chars a=1e9 s.each.with_index{|c,i|if c=='c' k=0 (i...s.size).each{|j| k+=1 if s[j]=='w' a=[a,j-i+1].min if k==2} end} p a>1e8?-1:a