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

    if (R - L + 1 >= 2019) {
        console.log(0);
    } else {
        const Lmod = L % 2019;
        const Rmod = R % 2019;
        if (Lmod > Rmod) {
            console.log(0);
        } else {
            console.log(L * (L + 1) % 2019);

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