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

  while (L >= 2019) {
    L = L % 2019;
  }
  R = L * R;
  console.log(R % 2019);
})(
  require("fs").readFileSync("/dev/stdin", "utf8")
);
