h = {"2"=>19892, "."=>1, "1"=>20063, "4"=>19874, "5"=>20199, "9"=>19841, "6"=>19898, "3"=>20011, "8"=>19956, "7"=>20163, "0"=>20104} _h = Hash.new{0} gets.chomp.chars.each do |c| _h[c] += 1 end ans = [] h.each do |k, v| if _h[k] > v ans[0] = k elsif _h[k] < v ans[1] = k end end puts "#{ans[0]} #{ans[1]}"