
object Main extends App {

  import scala.util.control.Breaks

  val b = new Breaks

  val Array(l, r) = scala.io.StdIn.readLine.split(" ").map(_.toInt)

  var min = l * (l + 1) % 2019
  var add = 1

  import b.{breakable, break}

  breakable {
    while (true) {
      if (l + add < r) {
        val tmp = l + add * (l + add + 1) % 2019
        if (tmp < min) {
          min = tmp
          if (min == 0) {
            break
          }
        }
        add += 1
      } else {
        break
      }
    }
  }

  println(min)
  //l * ? mod 2019 = 0
}
