L,R=gets.chomp.split(' ').map{|n| n.to_i}
a = (L/2019+1)*2019
a1 = (L/2019+1)*2019+1
a2 = (L/2019+1)*2019+2
b = (L/2019+2)*2019
b1 = (L/2019+2)*2019+1
b2 = (L/2019+2)*2019+2
if(L<=a && a<=R && L<=b && b<=R)
	puts 0
elsif(L<=a && a<=R)
	puts 0
else
	puts (L*(L+1)%2019)
end

