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

  var min = 2020
  (l until r).foreach { i =>
    val end = List(r, i + 2019).min
    (l + 1 to end).foreach { j =>
      val aa = i * j % 2019
      if (aa < min) {
        min = aa
      }

    }

  }
  println(min)
}
