object Main extends App {
  
  var a = readLine.split(" ").map(_.toInt)
  def b(c:Long,d:Long,e:Long,f:Long):Long = {
    if(d-c>2019){
      return 0
    }
    if(c+1>d) {
      return f
    } else {
      var g=if((c*(c+1))%2019<f)(c*(c+1))%2019 else f
      b(c+1,d,c*d%2019,g)
    }
  }
  print(b(a(0),a(1),2020,2020))
}