L, R = gets.chomp.split(" ").map(&:to_i)
l = L % 2019
r = R % 2019

if L / 2019 != R / 2019 || L == 0
    puts 0
elsif l < 4 && r > 672
    puts 0
else
    min = 2019
    for i in (l..r) do
        tmp = i * (i + 1) % 2019
        if min = tmp if tmp < min
    end
    puts min
end
