x,y=gets.split.map &:to_i
sum=[]
mai=[]
if (x-y).abs>=4038
  puts 0
else
  for i in x..y
    sum << [i%2019,2019-i%2019].min
    mai << i
  end
  ans=sum.zip(mai).sort
  puts (ans[0][1]*ans[1][1])%2019
end
