object Main extends App {
  val Array(l,r) = readLine.split(" ").map(_.toInt)
  val lm = l % 2019
  val rm = r - (l-lm)
  if(rm>=2019){
    println(0)
  }else{
    println((lm to rm).map{i =>
      (i+1 to rm).map{j => (i*j)%2019}.foldLeft(2019)(math.min(_,_))
    }.min)
  }
}