import scala.io.StdIn

object Main extends App {
  val Array(l, r)  = StdIn.readLine().split(" ").map(_.toInt)

  val lr = (l / 2019).floor
  val rr = (r / 2019).floor

  if (lr != rr) {
    println(0)
  } else {

    val lm = l % 2019
    val rm = r % 2019

    if (lm == 0 || rm == 0)
      println(0)
    else
      println(Array((lm * (lm + 1)) % 2019, ((rm - 1) * rm) % 2019).min)
//      println((lm  rm).combinations(2).map{ i => (i(0) * i(1)) % 2019 }.min)
  }
}
  

