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

  def loop(): Unit = {

  }

  def remainderMinimization2019(min: Long, max: Long): Long = {
    val divisor = 2019
    val startBlock = min / divisor
    val endBlock = max / divisor

    if (startBlock == endBlock) {
      if ((max - 1) * max / divisor == endBlock)
        ((min % divisor) * ((min + 1) % divisor)) % divisor
      else
        (for {
          i <- (min % divisor) to (max % divisor)
          j <- i + 1 to (max % divisor)
        } yield (i * j) % divisor).min
    }
    else //startBlock < endBlock
      ((min % divisor) * ((endBlock * divisor) % divisor)) % divisor
  }

  println(remainderMinimization2019(l, r))
}