object Main extends App {
  val input = io.StdIn.readLine().split(" ")
  val L = input(0).toInt
  val R = input(1).toInt

  import scala.util.control.Breaks
  val b = new Breaks

  // L以上R以下の整数の組み合わせを生成する
  val pairSet = scala.collection.mutable.Set.empty[(Int, Int)]
  var start = L
  while (start < R) {
    var pairTarget = start + 1
    while (pairTarget <= R) {
      pairSet.add((start, pairTarget))
      pairTarget += 1
    }
    start += 1
  }

  val DIV = 2019

  val resultSet = scala.collection.mutable.Set.empty[Int]
  import b.{break, breakable}
  breakable {
    for (p <- pairSet) {
      val (a1, a2) = p
      val r = (a1 * a2) % DIV
      if (r == 0) break()
      else resultSet.add(r)
    }
  }

  println(resultSet.min)
}