((input) => {
  const data = input.split('\n');
  const line1 = data[0].split(' ');
  const L = +line1[0];
  const R = +line1[1];

  if (R - L >= 2019 || L - L % 2019 + 2019 <= R) {
    console.log(0);
    return;
  }

  var l = L;
  while (l >= 2019) {
    l = l % 2019;
  }

  if (R - L === 1) {
    console.log(l * R % 2019);
    return;
  }

  console.log(Array(R - L).fill(null).reduce((result, _, n) => {
    if (n === 0) {
      return result;
    }
    return Math.min(result, l * (L + n) % 2019);
  }, Infinity));
})(
  require("fs").readFileSync("/dev/stdin", "utf8")
);
