puts gets.split.max{|a,b| a=a.reverse b=b.reverse c=a.size<=>b.size if c!=0 c else (0...a.size).each{|i|c=a[i]=='4'&&b[i]=='7' ? 1 : a[i]=='7'&&b[i]=='4' ? -1 : a[i]<=>b[i];break if c!=0} c end }[1]