#! ruby # yukicoder My Practice # author: Leonardone @ NEETSDKASU # 解説読後 # http://yukicoder.me/problems/686/editorial s = gets.chomp a = [0] * 10 s.each_char do |c| next if c == '.' a[c.to_i] += 1 end b = [20105, 20063, 19892, 20011, 19874, 20199, 19898, 20163, 19956, 19841] w = -1 c = -1 10.times do |i| d = b[i] - a[i] if d < 0 c = i elsif d > 0 w = i end end puts "%d %d" % [w, c]