'use strict'
function main(i) {
  i = i.trim().split(' ')
  const Y = 2019
  const R = Number(i[1])
  const L = Number(i[0])
  const diff = R - L

  const hasDivisible = diff - (R % Y)
  if (hasDivisible >= 0) {
    console.log(0)
  } else {
    let ans = -1
    for (let i = L; i < R; i++) {
      let n = (i * (i + 1)) % Y
      if (ans === -1 || n < ans) ans = n
    }
    console.log(ans)
  }
}
main(require('fs').readFileSync('/dev/stdin', 'utf8'));
