const main = (L,R) => {
    var result = 2018
    
    if(R - L >= 2019) {
        return 0
    }else{
        const ll = L%2019
        const rr = R%2019
        if(ll>rr) {
            return 0           
        }else{
            for(var i = L;i<R+1;i++) {
                for(var j = i+1;j<R+1;j++) {
                    result = Math.min(result,(i*j%2019))
                    if(i*j%2019===1) {
                    }
                }
            }
            return result
        }
    }
}

const input = require('fs').readFileSync('/dev/stdin','utf8').split("\n")[0]
const LR = input.split(" ").map(i => Number(i))
console.log(main(LR[0],LR[1]))