"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);
  let num = 0;
  for(let i=l; i<r; i++) {
    if (i%2019 == 0) num = 1;
  }
  // console.log(num);
  if (num == 1) {
    console.log(0);
  } else {
    console.log((l*(l+1))%2019);
  }
  
  
  
  
};
main(require("fs").readFileSync("/dev/stdin", "utf8").split('\n'));