import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int l = Integer.parseInt(sc.next());
        int r = Integer.parseInt(sc.next());
        int[] count = new int[2019];
        for(int i=l;i<l+4038 && i<=r;i++){
            count[i%2019]++;
        }
        int min = Integer.MAX_VALUE;
        for(int i=0;i<2019;i++){
            if(count[i]>1){
                min = Math.min(min,(i*i)%2019);
            }
            if(count[i] > 0){
                for(int j=i+1;j<2019;j++){
                    if(count[j] >0){
                        min = Math.min(min,(i*j)%2019);
                    }
                }
            }
        }
        System.out.println(min);
        sc.close();
    }

} import java.util.Scanner; Scanner java.util public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int l = Integer.parseInt(sc.next());
        int r = Integer.parseInt(sc.next());
        int[] count = new int[2019];
        for(int i=l;i<l+4038 && i<=r;i++){
            count[i%2019]++;
        }
        int min = Integer.MAX_VALUE;
        for(int i=0;i<2019;i++){
            if(count[i]>1){
                min = Math.min(min,(i*i)%2019);
            }
            if(count[i] > 0){
                for(int j=i+1;j<2019;j++){
                    if(count[j] >0){
                        min = Math.min(min,(i*j)%2019);
                    }
                }
            }
        }
        System.out.println(min);
        sc.close();
    }

} Main public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int l = Integer.parseInt(sc.next());
        int r = Integer.parseInt(sc.next());
        int[] count = new int[2019];
        for(int i=l;i<l+4038 && i<=r;i++){
            count[i%2019]++;
        }
        int min = Integer.MAX_VALUE;
        for(int i=0;i<2019;i++){
            if(count[i]>1){
                min = Math.min(min,(i*i)%2019);
            }
            if(count[i] > 0){
                for(int j=i+1;j<2019;j++){
                    if(count[j] >0){
                        min = Math.min(min,(i*j)%2019);
                    }
                }
            }
        }
        System.out.println(min);
        sc.close();
    } main {
        Scanner sc = new Scanner(System.in);
        int l = Integer.parseInt(sc.next());
        int r = Integer.parseInt(sc.next());
        int[] count = new int[2019];
        for(int i=l;i<l+4038 && i<=r;i++){
            count[i%2019]++;
        }
        int min = Integer.MAX_VALUE;
        for(int i=0;i<2019;i++){
            if(count[i]>1){
                min = Math.min(min,(i*i)%2019);
            }
            if(count[i] > 0){
                for(int j=i+1;j<2019;j++){
                    if(count[j] >0){
                        min = Math.min(min,(i*j)%2019);
                    }
                }
            }
        }
        System.out.println(min);
        sc.close();
    } Scanner sc = new Scanner(System.in); sc new Scanner(System.in) int l = Integer.parseInt(sc.next()); l Integer.parseInt(sc.next()) Integer.parseInt Integer sc.next() sc.next sc int r = Integer.parseInt(sc.next()); r Integer.parseInt(sc.next()) Integer.parseInt Integer sc.next() sc.next sc int[] count = new int[2019]; count new int[2019] 2019 for(int i=l;i<l+4038 && i<=r;i++){
            count[i%2019]++;
        } int i=l; int i=l; i l i<l+4038 && i<=r i<l+4038 i l+4038 l 4038 i<=r i r i++ i++ i {
            count[i%2019]++;
        } {
            count[i%2019]++;
        } count[i%2019]++ count[i%2019] count i%2019 i 2019 int min = Integer.MAX_VALUE; min Integer.MAX_VALUE Integer Integer.MAX_VALUE for(int i=0;i<2019;i++){
            if(count[i]>1){
                min = Math.min(min,(i*i)%2019);
            }
            if(count[i] > 0){
                for(int j=i+1;j<2019;j++){
                    if(count[j] >0){
                        min = Math.min(min,(i*j)%2019);
                    }
                }
            }
        } int i=0; int i=0; i 0 i<2019 i 2019 i++ i++ i {
            if(count[i]>1){
                min = Math.min(min,(i*i)%2019);
            }
            if(count[i] > 0){
                for(int j=i+1;j<2019;j++){
                    if(count[j] >0){
                        min = Math.min(min,(i*j)%2019);
                    }
                }
            }
        } {
            if(count[i]>1){
                min = Math.min(min,(i*i)%2019);
            }
            if(count[i] > 0){
                for(int j=i+1;j<2019;j++){
                    if(count[j] >0){
                        min = Math.min(min,(i*j)%2019);
                    }
                }
            }
        } if(count[i]>1){
                min = Math.min(min,(i*i)%2019);
            } count[i]>1 count[i] count i 1 {
                min = Math.min(min,(i*i)%2019);
            } min = Math.min(min,(i*i)%2019) min Math.min(min,(i*i)%2019) Math.min Math min (i*i)%2019 (i*i) i i 2019 if(count[i] > 0){
                for(int j=i+1;j<2019;j++){
                    if(count[j] >0){
                        min = Math.min(min,(i*j)%2019);
                    }
                }
            } count[i] > 0 count[i] count i 0 {
                for(int j=i+1;j<2019;j++){
                    if(count[j] >0){
                        min = Math.min(min,(i*j)%2019);
                    }
                }
            } for(int j=i+1;j<2019;j++){
                    if(count[j] >0){
                        min = Math.min(min,(i*j)%2019);
                    }
                } int j=i+1; int j=i+1; j i+1 i 1 j<2019 j 2019 j++ j++ j {
                    if(count[j] >0){
                        min = Math.min(min,(i*j)%2019);
                    }
                } {
                    if(count[j] >0){
                        min = Math.min(min,(i*j)%2019);
                    }
                } if(count[j] >0){
                        min = Math.min(min,(i*j)%2019);
                    } count[j] >0 count[j] count j 0 {
                        min = Math.min(min,(i*j)%2019);
                    } min = Math.min(min,(i*j)%2019) min Math.min(min,(i*j)%2019) Math.min Math min (i*j)%2019 (i*j) i j 2019 System.out.println(min) System.out.println System.out System System.out min sc.close() sc.close sc String[] args args public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int l = Integer.parseInt(sc.next());
        int r = Integer.parseInt(sc.next());
        int[] count = new int[2019];
        for(int i=l;i<l+4038 && i<=r;i++){
            count[i%2019]++;
        }
        int min = Integer.MAX_VALUE;
        for(int i=0;i<2019;i++){
            if(count[i]>1){
                min = Math.min(min,(i*i)%2019);
            }
            if(count[i] > 0){
                for(int j=i+1;j<2019;j++){
                    if(count[j] >0){
                        min = Math.min(min,(i*j)%2019);
                    }
                }
            }
        }
        System.out.println(min);
        sc.close();
    }

} public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int l = Integer.parseInt(sc.next());
        int r = Integer.parseInt(sc.next());
        int[] count = new int[2019];
        for(int i=l;i<l+4038 && i<=r;i++){
            count[i%2019]++;
        }
        int min = Integer.MAX_VALUE;
        for(int i=0;i<2019;i++){
            if(count[i]>1){
                min = Math.min(min,(i*i)%2019);
            }
            if(count[i] > 0){
                for(int j=i+1;j<2019;j++){
                    if(count[j] >0){
                        min = Math.min(min,(i*j)%2019);
                    }
                }
            }
        }
        System.out.println(min);
        sc.close();
    }

} Main
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int l = Integer.parseInt(sc.next());
        int r = Integer.parseInt(sc.next());
        int[] count = new int[2019];
        for(int i=l;i<l+4038 && i<=r;i++){
            count[i%2019]++;
        }
        int min = Integer.MAX_VALUE;
        for(int i=0;i<2019;i++){
            if(count[i]>1){
                min = Math.min(min,(i*i)%2019);
            }
            if(count[i] > 0){
                for(int j=i+1;j<2019;j++){
                    if(count[j] >0){
                        min = Math.min(min,(i*j)%2019);
                    }
                }
            }
        }
        System.out.println(min);
        sc.close();
    }

}