l, r = gets.chomp.split.map(&:to_i)
m = 2019
l.upto(r) do |i|
  s = []
  l.upto(i-1) do |j|
    c = i * j % 2019
    if !s.include?(c)
      s << c
    else
      s = []
      break
    end
    if c < m
      m = c
    end
    if c == 0
      puts 0
      exit
    end
  end
end
puts m
