object Main extends App {
  val sc = new java.util.Scanner(System.in)
  val l, r = sc.nextLong

  def remainderMinimization2019(min: Long, max: Long): Long = {
    val divisor = 2019
    val startBlock = min / divisor
    val endBlock = max / divisor
    val (i, j) =
      if (startBlock == endBlock) {
        (min, min + 1)
      } else {
        //startBlock < endBlock
        (min, endBlock * divisor)
      }
    ((i % divisor) * (j % divisor)) % divisor
  }

  println(remainderMinimization2019(l, r))
}