function main(input) {
  const inputList = input.split(/\s/).map(inp => formatNum(inp));
  const A = inputList[0];
  const B = inputList[1];
  const SET_NUM = 2019;
  var result;
  if ((Math.floor(A % SET_NUM) === 0) || (Math.floor(A / SET_NUM) < Math.floor(B / SET_NUM))) {
    result = 0;
  } else {
    result = (A * (A + 1)) % SET_NUM;
  }
  console.log(result);
};

// 文字列を数値に変換
function formatNum(str) {
  return Number(str);
};

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