'use strict'

const main = input => {
	const args = input.trim().split(' ').map(Number)
	const l = args[0]
	const r = args[1]

	if (l % 2019 <= r % 2019) {
		console.log(l * (l + 1) % 2019)
	} else {
		console.log(r * (r - 1) % 2019)
	}
}

main(require('fs').readFileSync('/dev/stdin', 'utf8'))
