# frozen_string_literal: true S = gets.chomp T = ((S.scan(/(?=(c[^cw]*?w[^w]*?w))/).map { |m| m[0].to_s.size }) + [S.size]) RESULT = (T.size == 1) ? -1 : (T.min) puts RESULT