s = gets if s =~ /^w+$/ || s !~ /w/ then puts exit end s.sub!(/w+/, "") max = s.scan(/w+/).map{|s| s.length}.max puts s.scan(/([^w]+)w{#{max}}/)