import sys

def input(): return sys.stdin.readline().rstrip()



def main():

    mod = 2019

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

    l_div = l // mod

    if mod * (l_div + 2) < r:

        print((0))

        quit()

    elif mod * (l_div + 1) < r:

        print((1))

        quit()

    ans = 2020

    r_mod = r % mod

    for i in range(l % mod, r_mod + 1):

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

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

    print(ans)



if __name__ == '__main__':

    main()

import sys

def input(): return sys.stdin.readline().rstrip()



def main():

    mod = 2019

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

    l_div = l // mod

    if mod * (l_div + 2) < r:

        print((0))

        quit()

    elif mod * (l_div + 1) < r:

        print((1))

        quit()

    ans = 2020

    r_mod_1 = r % mod + 1

    for i in range(l % mod, r_mod_1):

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

            ij_mod = i * j % mod

            if ans > ij_mod:

                ans = ij_mod

    print(ans)



if __name__ == '__main__':

    main()

import sys


def input():
    return sys.stdin.readline().rstrip()


def main():
    mod = 2019
    l, r = list(map(int, input().split()))
    l_div = l // mod
    if mod * (l_div + 2) < r:
        print((0))
        quit()
    elif mod * (l_div + 1) < r:
        print((1))
        quit()
    ans = 2020
    r_mod = r % mod
    for i in range(l % mod, r_mod + 1):
        for j in range(i + 1, r_mod + 1):
            ans = min(ans, i * j % mod)
    print(ans)


if __name__ == "__main__":
    main()

import sys


def input():
    return sys.stdin.readline().rstrip()


def main():
    mod = 2019
    l, r = list(map(int, input().split()))
    l_div = l // mod
    if mod * (l_div + 2) < r:
        print((0))
        quit()
    elif mod * (l_div + 1) < r:
        print((1))
        quit()
    ans = 2020
    r_mod_1 = r % mod + 1
    for i in range(l % mod, r_mod_1):
        for j in range(i + 1, r_mod_1):
            ij_mod = i * j % mod
            if ans > ij_mod:
                ans = ij_mod
    print(ans)


if __name__ == "__main__":
    main()

-    r_mod = r % mod -    for i in range(l % mod, r_mod + 1): -        for j in range(i + 1, r_mod + 1): -            ans = min(ans, i * j % mod) +    r_mod_1 = r % mod + 1 +    for i in range(l % mod, r_mod_1): +        for j in range(i + 1, r_mod_1): +            ij_mod = i * j % mod +            if ans > ij_mod: +                ans = ij_mod