D = [20104, 20063, 19892, 20011, 19874, 20199, 19898, 20163, 19956, 19841] S = gets.chomp counter = Hash.new(0) S.each_char do |s| counter[s] += 1 end res = [*'0'..'9'].map { |c| counter[c] } a = -1 b = -1 9.times do |i| next if res[i] == D[i] a = i if res[i] > D[i] b = i if res[i] < D[i] end puts [a, b].join(' ')