counts = [20104, 20063, 19892, 20011, 19874, 20199, 19898, 20163, 19956, 19841]
input = gets
before = nil
after = nil
(0..9).each{|n|
	case counts[n] - input.count(n.to_s)
	when -1
		before = n
	when 1
		after = n
	end
}
puts "#{before} #{after}"