import java.util.Scanner;

public class Main {

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int l = sc.nextInt();
        int r = sc.nextInt();

        long ans = solve(l, r);
        System.out.println(ans);
    }

    private static long solve(int l, int r) {
        long R = Math.min(l + 2019, r);
        long ans = 2018;
        for (long i = l; i <= R; i++) {
            for (long j = i + 1; j <= R; j++) {
                long x = i * j % 2019;
                ans = Math.min(ans, x);
                if (ans == 0) {
                    return 0;
                }
            }
        }
        return ans;
    }
} 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();
        int r = sc.nextInt();

        long ans = solve(l, r);
        System.out.println(ans);
    }

    private static long solve(int l, int r) {
        long R = Math.min(l + 2019, r);
        long ans = 2018;
        for (long i = l; i <= R; i++) {
            for (long j = i + 1; j <= R; j++) {
                long x = i * j % 2019;
                ans = Math.min(ans, x);
                if (ans == 0) {
                    return 0;
                }
            }
        }
        return ans;
    }
} Main public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int l = sc.nextInt();
        int r = sc.nextInt();

        long ans = solve(l, r);
        System.out.println(ans);
    } main {
        Scanner sc = new Scanner(System.in);
        int l = sc.nextInt();
        int r = sc.nextInt();

        long ans = solve(l, r);
        System.out.println(ans);
    } Scanner sc = new Scanner(System.in); sc new Scanner(System.in) int l = sc.nextInt(); l sc.nextInt() sc.nextInt sc int r = sc.nextInt(); r sc.nextInt() sc.nextInt sc long ans = solve(l, r); ans solve(l, r) solve l r System.out.println(ans) System.out.println System.out System System.out ans String[] args args private static long solve(int l, int r) {
        long R = Math.min(l + 2019, r);
        long ans = 2018;
        for (long i = l; i <= R; i++) {
            for (long j = i + 1; j <= R; j++) {
                long x = i * j % 2019;
                ans = Math.min(ans, x);
                if (ans == 0) {
                    return 0;
                }
            }
        }
        return ans;
    } solve {
        long R = Math.min(l + 2019, r);
        long ans = 2018;
        for (long i = l; i <= R; i++) {
            for (long j = i + 1; j <= R; j++) {
                long x = i * j % 2019;
                ans = Math.min(ans, x);
                if (ans == 0) {
                    return 0;
                }
            }
        }
        return ans;
    } long R = Math.min(l + 2019, r); R Math.min(l + 2019, r) Math.min Math l + 2019 l 2019 r long ans = 2018; ans 2018 for (long i = l; i <= R; i++) {
            for (long j = i + 1; j <= R; j++) {
                long x = i * j % 2019;
                ans = Math.min(ans, x);
                if (ans == 0) {
                    return 0;
                }
            }
        } long i = l; long i = l; i l i <= R i R i++ i++ i {
            for (long j = i + 1; j <= R; j++) {
                long x = i * j % 2019;
                ans = Math.min(ans, x);
                if (ans == 0) {
                    return 0;
                }
            }
        } {
            for (long j = i + 1; j <= R; j++) {
                long x = i * j % 2019;
                ans = Math.min(ans, x);
                if (ans == 0) {
                    return 0;
                }
            }
        } for (long j = i + 1; j <= R; j++) {
                long x = i * j % 2019;
                ans = Math.min(ans, x);
                if (ans == 0) {
                    return 0;
                }
            } long j = i + 1; long j = i + 1; j i + 1 i 1 j <= R j R j++ j++ j {
                long x = i * j % 2019;
                ans = Math.min(ans, x);
                if (ans == 0) {
                    return 0;
                }
            } {
                long x = i * j % 2019;
                ans = Math.min(ans, x);
                if (ans == 0) {
                    return 0;
                }
            } long x = i * j % 2019; x i * j % 2019 i * j i j 2019 ans = Math.min(ans, x) ans Math.min(ans, x) Math.min Math ans x if (ans == 0) {
                    return 0;
                } ans == 0 ans 0 {
                    return 0;
                } return 0; 0 return ans; ans 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();
        int r = sc.nextInt();

        long ans = solve(l, r);
        System.out.println(ans);
    }

    private static long solve(int l, int r) {
        long R = Math.min(l + 2019, r);
        long ans = 2018;
        for (long i = l; i <= R; i++) {
            for (long j = i + 1; j <= R; j++) {
                long x = i * j % 2019;
                ans = Math.min(ans, x);
                if (ans == 0) {
                    return 0;
                }
            }
        }
        return ans;
    }
} public class Main {

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int l = sc.nextInt();
        int r = sc.nextInt();

        long ans = solve(l, r);
        System.out.println(ans);
    }

    private static long solve(int l, int r) {
        long R = Math.min(l + 2019, r);
        long ans = 2018;
        for (long i = l; i <= R; i++) {
            for (long j = i + 1; j <= R; j++) {
                long x = i * j % 2019;
                ans = Math.min(ans, x);
                if (ans == 0) {
                    return 0;
                }
            }
        }
        return ans;
    }
} Main
import java.util.Scanner;

public class Main {

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int l = sc.nextInt();
        int r = sc.nextInt();

        long ans = solve(l, r);
        System.out.println(ans);
    }

    private static long solve(int l, int r) {
        long R = Math.min(l + 2019, r);
        long ans = 2018;
        for (long i = l; i <= R; i++) {
            for (long j = i + 1; j <= R; j++) {
                long x = i * j % 2019;
                ans = Math.min(ans, x);
                if (ans == 0) {
                    return 0;
                }
            }
        }
        return ans;
    }
}
