import math._ object Main { def calc(a: String, b: String): String = { if (a.length < b.length) return b if (a.length > b.length) return a for (i <- 0 to a.length-1) { if ((a(i) == '4' || a(i) == '7') && (b(i) == '4' || b(i) == '7')) { if (a(i) == max(a(i), b(i))) return b else return a } if (a(i) < b(i)) return b if (a(i) > b(i)) return a } return a } def main(args: Array[String]) { val sc = new java.util.Scanner(System.in) val a, b = sc.next println(calc(a, b)) } }