L,R = list(map(int,input().split()))

if R-L+1>=2019:

    print((0))

else:

    R = R%2019

    L = L%2019

    if R<L:

        print((0))

    else:

        cmin = 2019

        for i in range(L,R):

            for j in range(L+1,R+1):

                cmin = min(cmin,(i*j)%2019)

        print(cmin)
L,R = list(map(int,input().split()))

if R-L+1>=673:

    print((0))

else:

    cmin = 2019

    for i in range(L,R):

        for j in range(i+1,R+1):

            cmin = min(cmin,(i*j)%2019)

    print(cmin)
L, R = list(map(int, input().split()))
if R - L + 1 >= 2019:
    print((0))
else:
    R = R % 2019
    L = L % 2019
    if R < L:
        print((0))
    else:
        cmin = 2019
        for i in range(L, R):
            for j in range(L + 1, R + 1):
                cmin = min(cmin, (i * j) % 2019)
        print(cmin)

L, R = list(map(int, input().split()))
if R - L + 1 >= 673:
    print((0))
else:
    cmin = 2019
    for i in range(L, R):
        for j in range(i + 1, R + 1):
            cmin = min(cmin, (i * j) % 2019)
    print(cmin)

-if R - L + 1 >= 2019: +if R - L + 1 >= 673: -    R = R % 2019 -    L = L % 2019 -    if R < L: -        print((0)) -    else: -        cmin = 2019 -        for i in range(L, R): -            for j in range(L + 1, R + 1): -                cmin = min(cmin, (i * j) % 2019) -        print(cmin) +    cmin = 2019 +    for i in range(L, R): +        for j in range(i + 1, R + 1): +            cmin = min(cmin, (i * j) % 2019) +    print(cmin)