"use strict";
const main = input => {
  input = input[0].split(' ').map(val => parseInt(val, 10));
  const l = input[0], r = input[1];
  // console.log(l, r);
  const ll = l%2019, rr = r%2019;
  let num = 2018;
  if (r-l >= 2018) {
    console.log(0);
  } else {
    for(let i=ll; i<rr; i++) {
      for(let j=i+1; j<=rr; j++) {
        num = Math.min(num, (i*j)%2019);
      }
    }
    console.log(num);
  }  
};
main(require("fs").readFileSync("/dev/stdin", "utf8").split('\n'));