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