object Main extends App {
  var a = readLine.split(" ").map(_.toInt)
  var sum = 2020
    if(a(1)-a(0)<2019){
      for(i<-a(0) until a(1)) {
//        if(sum > (i * (i+1))%2019) {
          sum = Math.min(sum,(i * (i+1))%2019)
//        }
      }
    } else {
      sum = 0
    }
  print(sum)
}