"use strict"
function main(arg) {
    var data = arg.trim().split("\n")[0].split(' ').map(Number)
    var L = data[0]
    var R = data[1]
    var _L = (L % 2019)
    var _R = (R % 2019)
    var __L = (L - (L % 2019))
    var __R = (R - (R % 2019)) //2019 4038 ..
    var kL = (L - (L % 2019)) / 2019  
    var kR = (R - (R % 2019)) / 2019


    if (kL < kR) {
        if (_R === 0) {
            console.log(((R - 1) * R) % 2019)
            // console.log("2")
        } else {
            console.log((__R * (__R - 1)) % 2019)
            // console.log("3")
        }      
    } else {
        var vL = Math.abs(getNear2019(L) - L)
        var vR = Math.abs(getNear2019(R) - R)
        // console.log([vL,vR])
        if (vL < vR) {
            console.log(((L + 1) * L) % 2019)
            // console.log("0")
        } else {
            console.log(((R - 1) * R) % 2019)
            // console.log("1")
        }
    }
}
main(require('fs').readFileSync('/dev/stdin', 'utf8'));


function getNear2019(v) {
    var k = (v - (v % 2019)) / 2019
    var v1 = Math.abs(k * 2019 - v)
    var v2 = Math.abs((k+1) * 2019 - v)
    if (v1 > v2) {
        return (k+1) * 2019
    }
    return k * 2019
}