s=gets.chomp cww = s.scan(/c[^c]*?w[^w]*?w/) puts cww.empty? ? -1 : cww.sort.first.size