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