import Foundation

let array = readLine()!.componentsSeparatedByString(" ")
let left = Int(array[0])!
let right = Int(array[1])!

func getRemainder(l: Int, r: Int) -> Int {
  let normalResult = (l * (l + 1)) % 2019
  let iMod2019 = l % 2019
  
  if l == 0 {
    return 0
  }
  
  if l < 2019 {
    if 2019 % l == 0 {
      if 2019 / l <= r {
        return 0
      }
      return normalResult
    }
    if l + (2019 % l) <= r {
      return 0
    }
    return normalResult
  }
  
  if iMod2019 == 0 {
    return 0
  }
  
  if (l + 2019 - iMod2019) <= r {
    return 0
  }
  
  return normalResult
}

print(getRemainder(left, r: right))