gets h = Hash.new{0} gets.split.each do |a| h[a] += 1 end p h.select{|k,v| v==1}.to_a.count