s = gets.chomp.split("") c, w1, w2 = -1, -1, -1 s.each_with_index {|x, i| case x when "c" c = i when "w" if c != -1 if w1 == -1 w1 = i else if w2 == -1 w2 = i end end end end } if c == -1 || w1 == -1 || w2 == -1 puts -1 else puts w2 - c + 1 end