h = Hash.new{0} gets gets.split.each do |s| h[s] += 1 end puts h.select{|k,v| v == 1}.size