import scala.io.StdIn

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

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

  
  if (r % 2019 < lm) {
    println(0)
  } else if (lr != rr) {
    println(0)
  } else {
    val rm = r % 2019
    if (lm == 0 || rm == 0)
      println(0)
    else
      println((lm to rm).combinations(2).map{ i => (i(0) * i(1)) % 2019 }.min)
  }
}
  

