chars = gets.chomp.chars max = chars.length - 1 w_count = 0 res = [] count = 1 0.step(max) do |i| next if chars[i] != "c" (i + 1).step(max) do |j| count += 1 w_count += 1 if chars[j] == "w" if w_count == 2 res << count break end end count = 1 w_count = 0 end puts res.length == 0 ? "-1" : res.min