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