L, R = gets.split.map(&:to_i)

if (L..R).any? {|x| x % 2019 == 0 }
  puts 0
  exit
end

l = L % 2019
r = R % 2019

ans = (l..r).to_a.combination(2).map do |a, b|
  if a == b
    2018
  else
    (a * b) % 2019
  end
end.min

puts ans
