def fun(L,R):
    if R-L>=2019:
        return 0
    else:
        ll = L%2019
        rr = R%2019
        if ll>R:
            return 0
        else:
            r = 2018
            for i in range(L,R+1):
                for j in range(i+1,R+1):
                    r=min(r,i*j%2019)
            return r
        


L,R = [ int(i) for i in input().split(" ")]
print(fun(L,R))  