def min2(a,b)
    return a>b ? b : a
end
def max2(a,b)
    return a<b ? b : a
end


L,R = gets.split.map{|i| i.to_i}


if R - L >= 2018
    puts 0
    exit
end

lst =(L..R).map{|i| i % 2019}

len = lst.length
mn = 2018
for i in 0...(len-1)
    for j in 1...len
        
        mn = min2(mn,(lst[i]*lst[j])% 2019)

    end
end
puts mn