MOD = 2019
L, R = gets.split(' ').map(&:to_i)
  l = L%MOD
  r = R%MOD
if (l==0) || (r==0) || (L/MOD != R/MOD)
  puts 0
else
  min = 2018
  (l..r).each do |i|
    (i+1..r).each do |j|
      num = (i * j) % MOD
      min = num if num < min
      break if min == 0
    end
    break if min == 0
  end
  puts min
end