

function Main(input) {
  input = input.split("\n");
  var L = parseInt(input[0].split(" ")[0]);
  var R = parseInt(input[0].split(" ")[1]);
  var map = new Array(2019).fill(0);
  for(var i=0;i<2019;i++){
    tmp=new Array(2019).fill(0);
    for(var j=0;j<2019;j++){
      tmp[j]=(i*j)%2019;
    }
    map[i]=tmp;
  }
  var ans =2018;
  var min =2018;
  var max =0;
  for(var i=L;i<Math.min(R+1,L+2020);i++){
    min=Math.min(min,i%2019);
    max=Math.max(max,i%2019);
  }
  for(var i=min;i<max;i++){
    for(var j=i+1;j<=max;j++){
      ans=Math.min(ans,map[i][j]);
    }
  }

  console.log('%s', ans);
  return ans;
}

function debug(n){
  var input = document.getElementById("input"+n).value;
  var ans=Main(input);
  var result="WA";
  if(ans==document.getElementById("output"+n).value.split("\n")[0]){
    result="AC";
  }
  document.getElementById("result"+n).innerHTML=result;
}
Main(require("fs").readFileSync("/dev/stdin", "utf8"));