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



ans = 3000



for i in range(l, r):

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

    if (i * j) % 2019 < ans:

      ans = (i * j) % 2019

    if ans == 0:

      print(ans)

      exit() 

print(ans)
# coding: utf-8





def main():

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

    

    ans = 3000

    for i in range(l, r):

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

            candidate = (i * j) % 2019

            if candidate < ans:

                ans = candidate

            if ans == 0:

                return ans

    return ans





print((main()))

        



l, r = list(map(int, input().split()))
ans = 3000
for i in range(l, r):
    for j in range(i + 1, r + 1):
        if (i * j) % 2019 < ans:
            ans = (i * j) % 2019
        if ans == 0:
            print(ans)
            exit()
print(ans)

# coding: utf-8
def main():
    l, r = list(map(int, input().split(" ")))
    ans = 3000
    for i in range(l, r):
        for j in range(i + 1, r + 1):
            candidate = (i * j) % 2019
            if candidate < ans:
                ans = candidate
            if ans == 0:
                return ans
    return ans


print((main()))

-l, r = list(map(int, input().split())) -ans = 3000 -for i in range(l, r): -    for j in range(i + 1, r + 1): -        if (i * j) % 2019 < ans: -            ans = (i * j) % 2019 -        if ans == 0: -            print(ans) -            exit() -print(ans) +# coding: utf-8 +def main(): +    l, r = list(map(int, input().split(" "))) +    ans = 3000 +    for i in range(l, r): +        for j in range(i + 1, r + 1): +            candidate = (i * j) % 2019 +            if candidate < ans: +                ans = candidate +            if ans == 0: +                return ans +    return ans + + +print((main()))