s = gets.chomp.gsub(/^w/, '') cnt, longest = 0, 0 s.split('').each do |c| if c == 'w' cnt += 1 longest = longest < cnt ? cnt : longest else cnt = 0 end end if longest == 0 or longest == s.length puts return end s.split('w'*longest).each do |s| puts s.split('w').select{|item| item.length != 0}.last end