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