input = gets(chomp: true) cww = input.match(/c[^c]*?w.*?w/).to_s puts cww.empty? ? -1 : cww.size