L, R = (int(i) for i in input().split())



if (R - L) <= 2019:

    temp1 = float("inf")

    for i in range(R - L):

        for j in range(R - L):

            temp2 = ((R-i) * (R - 1 -j)) % 2019

            if temp2 < temp1:

                temp1 = temp2

    print(temp1)

else:

    temp1 = float("inf")

    for i in range(2019):

        if (R-i-1) < L:

            break

        for j in range(2019):

            temp2 = ((R - i) * (R - 1 - j)) % 2019

            if temp2 < temp1:

                temp1 = temp2

    print(temp1)
import sys



input = sys.stdin.readline





class Solution:

    def main(self):

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



        ans = 2019

        for i in range(L, min(R + 1, L + 2019)):

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

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



        print(ans)





# Run main

if __name__ == '__main__':

    Solution().main()

L, R = (int(i) for i in input().split())
if (R - L) <= 2019:
    temp1 = float("inf")
    for i in range(R - L):
        for j in range(R - L):
            temp2 = ((R - i) * (R - 1 - j)) % 2019
            if temp2 < temp1:
                temp1 = temp2
    print(temp1)
else:
    temp1 = float("inf")
    for i in range(2019):
        if (R - i - 1) < L:
            break
        for j in range(2019):
            temp2 = ((R - i) * (R - 1 - j)) % 2019
            if temp2 < temp1:
                temp1 = temp2
    print(temp1)

import sys

input = sys.stdin.readline


class Solution:
    def main(self):
        L, R = list(map(int, input().split()))
        ans = 2019
        for i in range(L, min(R + 1, L + 2019)):
            for j in range(i + 1, min(R + 1, L + 2019)):
                ans = min(ans, (i * j) % 2019)
        print(ans)


# Run main
if __name__ == "__main__":
    Solution().main()

-L, R = (int(i) for i in input().split()) -if (R - L) <= 2019: -    temp1 = float("inf") -    for i in range(R - L): -        for j in range(R - L): -            temp2 = ((R - i) * (R - 1 - j)) % 2019 -            if temp2 < temp1: -                temp1 = temp2 -    print(temp1) -else: -    temp1 = float("inf") -    for i in range(2019): -        if (R - i - 1) < L: -            break -        for j in range(2019): -            temp2 = ((R - i) * (R - 1 - j)) % 2019 -            if temp2 < temp1: -                temp1 = temp2 -    print(temp1) +import sys + +input = sys.stdin.readline + + +class Solution: +    def main(self): +        L, R = list(map(int, input().split())) +        ans = 2019 +        for i in range(L, min(R + 1, L + 2019)): +            for j in range(i + 1, min(R + 1, L + 2019)): +                ans = min(ans, (i * j) % 2019) +        print(ans) + + +# Run main +if __name__ == "__main__": +    Solution().main()