input = gets.match(/c[^w]*w[^w]*w/).to_a.map(&:size) puts input.empty? ? -1 : input.min