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

min = { v: -1, mod: 2019 }

(L..R).each do |n|
  mod = n % 2019
  if mod == 0 && min[:mod] == 0
    puts 0
    exit
  end
  min = { v: n, mod: mod } if min[:mod] > mod
end

puts (min[:v] * (min[:v] + 1)) % 2019
