def judge(a) return a.uniq.size == 3 && (a.max == a[1] || a.min == a[1]) end s = gets.chomp ans = "" [?1, ?4].each do |c| if judge(s.tr(??,c).split.map(&:to_i)) ans += c end end puts ans