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

if R-L+1>=2019:

    print((0))

else:

    m=2019

    for i in range(L,R):

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

            x=(i*j)%2019

            if x<m:

                m=x

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

if R-L+1>=671:

    print((0))

else:

    m=2019

    for i in range(L,R):

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

            x=(i*j)%2019

            if x<m:

                m=x

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

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

-if R - L + 1 >= 2019: +if R - L + 1 >= 671: