'use strict'
function main(input) {
    const tmp = input.split(' ');
    const L = parseInt(tmp[0], 10);
    const R = parseInt(tmp[1], 10);

    if (R < 2019) {
        console.log(L * (L + 1) % 2019);
    } else {
        const Lmod = L % 2019;
        const Rmod = R % 2019;
        const distL = Lmod;
        const distR = Math.abs(2019 - Rmod);

        if (distL < distR) {
            console.log(Lmod * (Lmod + 1) % 2019);
        } else {
            console.log(Rmod * (Rmod + 1) % 2019);
        }
    }
}
main(require('fs').readFileSync('/dev/stdin', 'utf8'));