fun readLargeInt () = valOf (TextIO.scanStream (LargeInt.scan StringCvt.DEC) TextIO.stdIn) val () = let val x = readLargeInt () val y = readLargeInt () val x2 = readLargeInt () val y2 = readLargeInt () val ans = if x = y andalso x2 = y2 andalso x2 < x then x + 1 else LargeInt.max (x, y) in print (LargeInt.toString ans ^ "\n") end