fun readInt () = valOf (TextIO.scanStream (Int.scan StringCvt.DEC) TextIO.stdIn) fun findAns l r = let fun findAnsLoop limit current arr = if current = limit then Array.foldl (fn (x, acc) => if x = true then acc + 1 else acc) 0 arr else ( if 1 <= current andalso current <= 295 then Array.update (arr, 0, true) else if 296 <= current andalso current <= 416 then Array.update (arr, 1, true) else Array.update (arr, 2, true); findAnsLoop limit (current + 1) arr ) in findAnsLoop (r + 1) l (Array.array (3, false)) - 1 end val () = let val l = readInt () val r = readInt () val ans = findAns l r in print (Int.toString ans ^ "\n") end