l, r = gets.split.map &:to_i
p 0 if r-l>=673
ans = Float::INFINITY
(l...r).each do |_i|
  i = _i%2019
  (_i+1..r).each do |j|
    m = i*j%2019
    ans = m if m < ans
    if ans==0
      p 0
      exit
    end
  end
end
p ans
