import java.io.BufferedReader;
import java.io.InputStreamReader;

public class Main {

    public static void main(String[] args) throws Exception {
        try (BufferedReader reader = new BufferedReader(new InputStreamReader(System.in))) {
            int[] array = readIntArray(reader);
            int L = array[0];
            int R = array[1];

            if (L + 2019 <= R) {
                System.out.println(0);
                System.exit(0);
            }

            L %= 2019;
            R %= 2019;
            if (R <= L) {
                System.out.println(0);
                System.exit(0);
            }

            int mod = 2019;
            for (int i = L; i <= R; i++) {
                for (int j = i + 1; j <= R; j++) {
                    int m = (i * j) % 2019;
                    if (m < mod) {
                        mod = m;
                    }
                }
            }

            System.out.println(mod);
        }
    }

    public static int[] readIntArray(BufferedReader reader) throws Exception {
        String[] str = reader.readLine().split(" ");
        int[] array = new int[str.length];
        for (int i = 0; i < str.length; i++) {
            array[i] = Integer.parseInt(str[i]);
        }
        return array;
    }

} import java.io.BufferedReader; BufferedReader java.io import java.io.InputStreamReader; InputStreamReader java.io public class Main {

    public static void main(String[] args) throws Exception {
        try (BufferedReader reader = new BufferedReader(new InputStreamReader(System.in))) {
            int[] array = readIntArray(reader);
            int L = array[0];
            int R = array[1];

            if (L + 2019 <= R) {
                System.out.println(0);
                System.exit(0);
            }

            L %= 2019;
            R %= 2019;
            if (R <= L) {
                System.out.println(0);
                System.exit(0);
            }

            int mod = 2019;
            for (int i = L; i <= R; i++) {
                for (int j = i + 1; j <= R; j++) {
                    int m = (i * j) % 2019;
                    if (m < mod) {
                        mod = m;
                    }
                }
            }

            System.out.println(mod);
        }
    }

    public static int[] readIntArray(BufferedReader reader) throws Exception {
        String[] str = reader.readLine().split(" ");
        int[] array = new int[str.length];
        for (int i = 0; i < str.length; i++) {
            array[i] = Integer.parseInt(str[i]);
        }
        return array;
    }

} Main public static void main(String[] args) throws Exception {
        try (BufferedReader reader = new BufferedReader(new InputStreamReader(System.in))) {
            int[] array = readIntArray(reader);
            int L = array[0];
            int R = array[1];

            if (L + 2019 <= R) {
                System.out.println(0);
                System.exit(0);
            }

            L %= 2019;
            R %= 2019;
            if (R <= L) {
                System.out.println(0);
                System.exit(0);
            }

            int mod = 2019;
            for (int i = L; i <= R; i++) {
                for (int j = i + 1; j <= R; j++) {
                    int m = (i * j) % 2019;
                    if (m < mod) {
                        mod = m;
                    }
                }
            }

            System.out.println(mod);
        }
    } main {
        try (BufferedReader reader = new BufferedReader(new InputStreamReader(System.in))) {
            int[] array = readIntArray(reader);
            int L = array[0];
            int R = array[1];

            if (L + 2019 <= R) {
                System.out.println(0);
                System.exit(0);
            }

            L %= 2019;
            R %= 2019;
            if (R <= L) {
                System.out.println(0);
                System.exit(0);
            }

            int mod = 2019;
            for (int i = L; i <= R; i++) {
                for (int j = i + 1; j <= R; j++) {
                    int m = (i * j) % 2019;
                    if (m < mod) {
                        mod = m;
                    }
                }
            }

            System.out.println(mod);
        }
    } try (BufferedReader reader = new BufferedReader(new InputStreamReader(System.in))) {
            int[] array = readIntArray(reader);
            int L = array[0];
            int R = array[1];

            if (L + 2019 <= R) {
                System.out.println(0);
                System.exit(0);
            }

            L %= 2019;
            R %= 2019;
            if (R <= L) {
                System.out.println(0);
                System.exit(0);
            }

            int mod = 2019;
            for (int i = L; i <= R; i++) {
                for (int j = i + 1; j <= R; j++) {
                    int m = (i * j) % 2019;
                    if (m < mod) {
                        mod = m;
                    }
                }
            }

            System.out.println(mod);
        } {
            int[] array = readIntArray(reader);
            int L = array[0];
            int R = array[1];

            if (L + 2019 <= R) {
                System.out.println(0);
                System.exit(0);
            }

            L %= 2019;
            R %= 2019;
            if (R <= L) {
                System.out.println(0);
                System.exit(0);
            }

            int mod = 2019;
            for (int i = L; i <= R; i++) {
                for (int j = i + 1; j <= R; j++) {
                    int m = (i * j) % 2019;
                    if (m < mod) {
                        mod = m;
                    }
                }
            }

            System.out.println(mod);
        } BufferedReader reader = new BufferedReader(new InputStreamReader(System.in)) BufferedReader reader = new BufferedReader(new InputStreamReader(System.in)) new BufferedReader(new InputStreamReader(System.in)) int[] array = readIntArray(reader); array readIntArray(reader) readIntArray reader int L = array[0]; L array[0] array 0 int R = array[1]; R array[1] array 1 if (L + 2019 <= R) {
                System.out.println(0);
                System.exit(0);
            } L + 2019 <= R L + 2019 L 2019 R {
                System.out.println(0);
                System.exit(0);
            } System.out.println(0) System.out.println System.out System System.out 0 System.exit(0) System.exit System 0 L %= 2019 L 2019 R %= 2019 R 2019 if (R <= L) {
                System.out.println(0);
                System.exit(0);
            } R <= L R L {
                System.out.println(0);
                System.exit(0);
            } System.out.println(0) System.out.println System.out System System.out 0 System.exit(0) System.exit System 0 int mod = 2019; mod 2019 for (int i = L; i <= R; i++) {
                for (int j = i + 1; j <= R; j++) {
                    int m = (i * j) % 2019;
                    if (m < mod) {
                        mod = m;
                    }
                }
            } int i = L; int i = L; i L i <= R i R i++ i++ i {
                for (int j = i + 1; j <= R; j++) {
                    int m = (i * j) % 2019;
                    if (m < mod) {
                        mod = m;
                    }
                }
            } {
                for (int j = i + 1; j <= R; j++) {
                    int m = (i * j) % 2019;
                    if (m < mod) {
                        mod = m;
                    }
                }
            } for (int j = i + 1; j <= R; j++) {
                    int m = (i * j) % 2019;
                    if (m < mod) {
                        mod = m;
                    }
                } int j = i + 1; int j = i + 1; j i + 1 i 1 j <= R j R j++ j++ j {
                    int m = (i * j) % 2019;
                    if (m < mod) {
                        mod = m;
                    }
                } {
                    int m = (i * j) % 2019;
                    if (m < mod) {
                        mod = m;
                    }
                } int m = (i * j) % 2019; m (i * j) % 2019 (i * j) i j 2019 if (m < mod) {
                        mod = m;
                    } m < mod m mod {
                        mod = m;
                    } mod = m mod m System.out.println(mod) System.out.println System.out System System.out mod String[] args args public static int[] readIntArray(BufferedReader reader) throws Exception {
        String[] str = reader.readLine().split(" ");
        int[] array = new int[str.length];
        for (int i = 0; i < str.length; i++) {
            array[i] = Integer.parseInt(str[i]);
        }
        return array;
    } readIntArray {
        String[] str = reader.readLine().split(" ");
        int[] array = new int[str.length];
        for (int i = 0; i < str.length; i++) {
            array[i] = Integer.parseInt(str[i]);
        }
        return array;
    } String[] str = reader.readLine().split(" "); str reader.readLine().split(" ") reader.readLine().split reader.readLine() reader.readLine reader " " int[] array = new int[str.length]; array new int[str.length] str.length str str.length for (int i = 0; i < str.length; i++) {
            array[i] = Integer.parseInt(str[i]);
        } int i = 0; int i = 0; i 0 i < str.length i str.length str str.length i++ i++ i {
            array[i] = Integer.parseInt(str[i]);
        } {
            array[i] = Integer.parseInt(str[i]);
        } array[i] = Integer.parseInt(str[i]) array[i] array i Integer.parseInt(str[i]) Integer.parseInt Integer str[i] str i return array; array BufferedReader reader reader public class Main {

    public static void main(String[] args) throws Exception {
        try (BufferedReader reader = new BufferedReader(new InputStreamReader(System.in))) {
            int[] array = readIntArray(reader);
            int L = array[0];
            int R = array[1];

            if (L + 2019 <= R) {
                System.out.println(0);
                System.exit(0);
            }

            L %= 2019;
            R %= 2019;
            if (R <= L) {
                System.out.println(0);
                System.exit(0);
            }

            int mod = 2019;
            for (int i = L; i <= R; i++) {
                for (int j = i + 1; j <= R; j++) {
                    int m = (i * j) % 2019;
                    if (m < mod) {
                        mod = m;
                    }
                }
            }

            System.out.println(mod);
        }
    }

    public static int[] readIntArray(BufferedReader reader) throws Exception {
        String[] str = reader.readLine().split(" ");
        int[] array = new int[str.length];
        for (int i = 0; i < str.length; i++) {
            array[i] = Integer.parseInt(str[i]);
        }
        return array;
    }

} public class Main {

    public static void main(String[] args) throws Exception {
        try (BufferedReader reader = new BufferedReader(new InputStreamReader(System.in))) {
            int[] array = readIntArray(reader);
            int L = array[0];
            int R = array[1];

            if (L + 2019 <= R) {
                System.out.println(0);
                System.exit(0);
            }

            L %= 2019;
            R %= 2019;
            if (R <= L) {
                System.out.println(0);
                System.exit(0);
            }

            int mod = 2019;
            for (int i = L; i <= R; i++) {
                for (int j = i + 1; j <= R; j++) {
                    int m = (i * j) % 2019;
                    if (m < mod) {
                        mod = m;
                    }
                }
            }

            System.out.println(mod);
        }
    }

    public static int[] readIntArray(BufferedReader reader) throws Exception {
        String[] str = reader.readLine().split(" ");
        int[] array = new int[str.length];
        for (int i = 0; i < str.length; i++) {
            array[i] = Integer.parseInt(str[i]);
        }
        return array;
    }

} Main
import java.io.BufferedReader;
import java.io.InputStreamReader;

public class Main {

    public static void main(String[] args) throws Exception {
        try (BufferedReader reader = new BufferedReader(new InputStreamReader(System.in))) {
            int[] array = readIntArray(reader);
            int L = array[0];
            int R = array[1];

            if (L + 2019 <= R) {
                System.out.println(0);
                System.exit(0);
            }

            L %= 2019;
            R %= 2019;
            if (R <= L) {
                System.out.println(0);
                System.exit(0);
            }

            int mod = 2019;
            for (int i = L; i <= R; i++) {
                for (int j = i + 1; j <= R; j++) {
                    int m = (i * j) % 2019;
                    if (m < mod) {
                        mod = m;
                    }
                }
            }

            System.out.println(mod);
        }
    }

    public static int[] readIntArray(BufferedReader reader) throws Exception {
        String[] str = reader.readLine().split(" ");
        int[] array = new int[str.length];
        for (int i = 0; i < str.length; i++) {
            array[i] = Integer.parseInt(str[i]);
        }
        return array;
    }

}
