base = gets.split(' ').map {|i| i.to_i}
l = base[0]
r = base[1]

min = nil

def over?(current_r, r)
  current_r > r
end

current_l = l
current_r = current_l + 1

if over?(current_r, r)
  puts min
  exit
end

while true do
  #puts "#{current_l}, #{current_r}"
  _m = current_l * current_r
  if _m < 2019
    m = _m
  else
    m = _m % 2019
  end

  if m == 0
    puts 0
    exit
  end
  if min == nil
    min = m
  elsif m < min
    min = m
  end

  current_r = current_r + 1

  if over?(current_r, r)
    if current_l == r - 1
      puts min
      exit
    end
    current_l += 1
    current_r = current_l + 1
  end
end
