#!/bin/ruby S = gets.chomp cwws = S.scan(/c.*?w.*?w.*?/) if cwws.any? cwws.sort { |a, b| a.size <=> b.size } puts cwws[0].length else puts -1 end