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