l,r = list(map(int,input().split()))



if r - l > 2019:

    print((0))

else:

    tres = 2019

    for i in range(l,r):

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

            mod = (i % 2019) * (j % 2019) % 2019

            tres = min(tres,mod)

    print(tres)

l,r = list(map(int,input().split()))



if r - l > 2019:

    print((0))

else:

    tres = 2019

    for i in range(l,r):

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

            mod = (i % 2019) * (j % 2019) % 2019

            tres = min(tres,mod)

            if tres == 0:

                break

        if tres == 0:

            break

    print(tres)

l, r = list(map(int, input().split()))
if r - l > 2019:
    print((0))
else:
    tres = 2019
    for i in range(l, r):
        for j in range(i + 1, r + 1):
            mod = (i % 2019) * (j % 2019) % 2019
            tres = min(tres, mod)
    print(tres)

l, r = list(map(int, input().split()))
if r - l > 2019:
    print((0))
else:
    tres = 2019
    for i in range(l, r):
        for j in range(i + 1, r + 1):
            mod = (i % 2019) * (j % 2019) % 2019
            tres = min(tres, mod)
            if tres == 0:
                break
        if tres == 0:
            break
    print(tres)

+            if tres == 0: +                break +        if tres == 0: +            break