s=gets.chomp a=(0...s.size).map{|i|(0..s.size).map{|j|s[i..i+j].match(/c.*w.*w/)?j:1e5}}.flatten.min p a>1e4?-1:a