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