import java.util.Scanner;

public class Main {
    //
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int l = sc.nextInt(), r = sc.nextInt();
        System.out.println(sln(l, r));
        sc.close();
    }

    static int sln(int l, int r) {
        if (r - l >= 2019) return 0;
        int res = 2019;
        for (int i = l; i < r; i++) {
            for (int j = i + 1; j <= r; j++) {
                int mod = ((j % 2019) * (i % 2019)) % 2019;
                res = Math.min(res, mod);
            }
        }
        return res;
    }
} import java.util.Scanner; Scanner java.util public class Main {
    //
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int l = sc.nextInt(), r = sc.nextInt();
        System.out.println(sln(l, r));
        sc.close();
    }

    static int sln(int l, int r) {
        if (r - l >= 2019) return 0;
        int res = 2019;
        for (int i = l; i < r; i++) {
            for (int j = i + 1; j <= r; j++) {
                int mod = ((j % 2019) * (i % 2019)) % 2019;
                res = Math.min(res, mod);
            }
        }
        return res;
    }
} Main //
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int l = sc.nextInt(), r = sc.nextInt();
        System.out.println(sln(l, r));
        sc.close();
    } main {
        Scanner sc = new Scanner(System.in);
        int l = sc.nextInt(), r = sc.nextInt();
        System.out.println(sln(l, r));
        sc.close();
    } Scanner sc = new Scanner(System.in); sc new Scanner(System.in) int l = sc.nextInt() l sc.nextInt() sc.nextInt sc r = sc.nextInt(); r sc.nextInt() sc.nextInt sc System.out.println(sln(l, r)) System.out.println System.out System System.out sln(l, r) sln l r sc.close() sc.close sc String[] args args static int sln(int l, int r) {
        if (r - l >= 2019) return 0;
        int res = 2019;
        for (int i = l; i < r; i++) {
            for (int j = i + 1; j <= r; j++) {
                int mod = ((j % 2019) * (i % 2019)) % 2019;
                res = Math.min(res, mod);
            }
        }
        return res;
    } sln {
        if (r - l >= 2019) return 0;
        int res = 2019;
        for (int i = l; i < r; i++) {
            for (int j = i + 1; j <= r; j++) {
                int mod = ((j % 2019) * (i % 2019)) % 2019;
                res = Math.min(res, mod);
            }
        }
        return res;
    } if (r - l >= 2019) return 0; r - l >= 2019 r - l r l 2019 return 0; 0 int res = 2019; res 2019 for (int i = l; i < r; i++) {
            for (int j = i + 1; j <= r; j++) {
                int mod = ((j % 2019) * (i % 2019)) % 2019;
                res = Math.min(res, mod);
            }
        } int i = l; int i = l; i l i < r i r i++ i++ i {
            for (int j = i + 1; j <= r; j++) {
                int mod = ((j % 2019) * (i % 2019)) % 2019;
                res = Math.min(res, mod);
            }
        } {
            for (int j = i + 1; j <= r; j++) {
                int mod = ((j % 2019) * (i % 2019)) % 2019;
                res = Math.min(res, mod);
            }
        } for (int j = i + 1; j <= r; j++) {
                int mod = ((j % 2019) * (i % 2019)) % 2019;
                res = Math.min(res, mod);
            } int j = i + 1; int j = i + 1; j i + 1 i 1 j <= r j r j++ j++ j {
                int mod = ((j % 2019) * (i % 2019)) % 2019;
                res = Math.min(res, mod);
            } {
                int mod = ((j % 2019) * (i % 2019)) % 2019;
                res = Math.min(res, mod);
            } int mod = ((j % 2019) * (i % 2019)) % 2019; mod ((j % 2019) * (i % 2019)) % 2019 ((j % 2019) * (i % 2019)) (j % 2019) j 2019 (i % 2019) i 2019 2019 res = Math.min(res, mod) res Math.min(res, mod) Math.min Math res mod return res; res int l l int r r public class Main {
    //
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int l = sc.nextInt(), r = sc.nextInt();
        System.out.println(sln(l, r));
        sc.close();
    }

    static int sln(int l, int r) {
        if (r - l >= 2019) return 0;
        int res = 2019;
        for (int i = l; i < r; i++) {
            for (int j = i + 1; j <= r; j++) {
                int mod = ((j % 2019) * (i % 2019)) % 2019;
                res = Math.min(res, mod);
            }
        }
        return res;
    }
} public class Main {
    //
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int l = sc.nextInt(), r = sc.nextInt();
        System.out.println(sln(l, r));
        sc.close();
    }

    static int sln(int l, int r) {
        if (r - l >= 2019) return 0;
        int res = 2019;
        for (int i = l; i < r; i++) {
            for (int j = i + 1; j <= r; j++) {
                int mod = ((j % 2019) * (i % 2019)) % 2019;
                res = Math.min(res, mod);
            }
        }
        return res;
    }
} Main
import java.util.Scanner;

public class Main {
    //
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int l = sc.nextInt(), r = sc.nextInt();
        System.out.println(sln(l, r));
        sc.close();
    }

    static int sln(int l, int r) {
        if (r - l >= 2019) return 0;
        int res = 2019;
        for (int i = l; i < r; i++) {
            for (int j = i + 1; j <= r; j++) {
                int mod = ((j % 2019) * (i % 2019)) % 2019;
                res = Math.min(res, mod);
            }
        }
        return res;
    }
}
