import java.util.Scanner;

public class Main {
    
    public static void main (String[] args){
        
      Scanner sc = new Scanner (System.in);
        
        long L = sc.nextLong();
        long R = sc.nextLong();
        
        if (R>=2019&&L<=2019){
            System.out.println(0);
        } else {
            long min = Long.MAX_VALUE;
            boolean flag = true;
            
            for (long index=L; index<R; index++){
                if (flag==false){
                    break;
                }
                for (long index2=index+1; index2<=R; index2++){
                    if ((index*index2)%2019==0){
                        flag = false;
                        min=0;
                        break;
                    }
                    if (min>(index*index2)%2019){
                        min=(index*index2)%2019;
                    }
                }
            }
            System.out.println(min);
        }
    }
} import java.util.Scanner; Scanner java.util public class Main {
    
    public static void main (String[] args){
        
      Scanner sc = new Scanner (System.in);
        
        long L = sc.nextLong();
        long R = sc.nextLong();
        
        if (R>=2019&&L<=2019){
            System.out.println(0);
        } else {
            long min = Long.MAX_VALUE;
            boolean flag = true;
            
            for (long index=L; index<R; index++){
                if (flag==false){
                    break;
                }
                for (long index2=index+1; index2<=R; index2++){
                    if ((index*index2)%2019==0){
                        flag = false;
                        min=0;
                        break;
                    }
                    if (min>(index*index2)%2019){
                        min=(index*index2)%2019;
                    }
                }
            }
            System.out.println(min);
        }
    }
} Main public static void main (String[] args){
        
      Scanner sc = new Scanner (System.in);
        
        long L = sc.nextLong();
        long R = sc.nextLong();
        
        if (R>=2019&&L<=2019){
            System.out.println(0);
        } else {
            long min = Long.MAX_VALUE;
            boolean flag = true;
            
            for (long index=L; index<R; index++){
                if (flag==false){
                    break;
                }
                for (long index2=index+1; index2<=R; index2++){
                    if ((index*index2)%2019==0){
                        flag = false;
                        min=0;
                        break;
                    }
                    if (min>(index*index2)%2019){
                        min=(index*index2)%2019;
                    }
                }
            }
            System.out.println(min);
        }
    } main {
        
      Scanner sc = new Scanner (System.in);
        
        long L = sc.nextLong();
        long R = sc.nextLong();
        
        if (R>=2019&&L<=2019){
            System.out.println(0);
        } else {
            long min = Long.MAX_VALUE;
            boolean flag = true;
            
            for (long index=L; index<R; index++){
                if (flag==false){
                    break;
                }
                for (long index2=index+1; index2<=R; index2++){
                    if ((index*index2)%2019==0){
                        flag = false;
                        min=0;
                        break;
                    }
                    if (min>(index*index2)%2019){
                        min=(index*index2)%2019;
                    }
                }
            }
            System.out.println(min);
        }
    } Scanner sc = new Scanner (System.in); sc new Scanner (System.in) long L = sc.nextLong(); L sc.nextLong() sc.nextLong sc long R = sc.nextLong(); R sc.nextLong() sc.nextLong sc if (R>=2019&&L<=2019){
            System.out.println(0);
        } else {
            long min = Long.MAX_VALUE;
            boolean flag = true;
            
            for (long index=L; index<R; index++){
                if (flag==false){
                    break;
                }
                for (long index2=index+1; index2<=R; index2++){
                    if ((index*index2)%2019==0){
                        flag = false;
                        min=0;
                        break;
                    }
                    if (min>(index*index2)%2019){
                        min=(index*index2)%2019;
                    }
                }
            }
            System.out.println(min);
        } R>=2019&&L<=2019 R>=2019 R 2019 L<=2019 L 2019 {
            System.out.println(0);
        } System.out.println(0) System.out.println System.out System System.out 0 {
            long min = Long.MAX_VALUE;
            boolean flag = true;
            
            for (long index=L; index<R; index++){
                if (flag==false){
                    break;
                }
                for (long index2=index+1; index2<=R; index2++){
                    if ((index*index2)%2019==0){
                        flag = false;
                        min=0;
                        break;
                    }
                    if (min>(index*index2)%2019){
                        min=(index*index2)%2019;
                    }
                }
            }
            System.out.println(min);
        } long min = Long.MAX_VALUE; min Long.MAX_VALUE Long Long.MAX_VALUE boolean flag = true; flag true for (long index=L; index<R; index++){
                if (flag==false){
                    break;
                }
                for (long index2=index+1; index2<=R; index2++){
                    if ((index*index2)%2019==0){
                        flag = false;
                        min=0;
                        break;
                    }
                    if (min>(index*index2)%2019){
                        min=(index*index2)%2019;
                    }
                }
            } long index=L; long index=L; index L index<R index R index++ index++ index {
                if (flag==false){
                    break;
                }
                for (long index2=index+1; index2<=R; index2++){
                    if ((index*index2)%2019==0){
                        flag = false;
                        min=0;
                        break;
                    }
                    if (min>(index*index2)%2019){
                        min=(index*index2)%2019;
                    }
                }
            } {
                if (flag==false){
                    break;
                }
                for (long index2=index+1; index2<=R; index2++){
                    if ((index*index2)%2019==0){
                        flag = false;
                        min=0;
                        break;
                    }
                    if (min>(index*index2)%2019){
                        min=(index*index2)%2019;
                    }
                }
            } if (flag==false){
                    break;
                } flag==false flag false {
                    break;
                } break; for (long index2=index+1; index2<=R; index2++){
                    if ((index*index2)%2019==0){
                        flag = false;
                        min=0;
                        break;
                    }
                    if (min>(index*index2)%2019){
                        min=(index*index2)%2019;
                    }
                } long index2=index+1; long index2=index+1; index2 index+1 index 1 index2<=R index2 R index2++ index2++ index2 {
                    if ((index*index2)%2019==0){
                        flag = false;
                        min=0;
                        break;
                    }
                    if (min>(index*index2)%2019){
                        min=(index*index2)%2019;
                    }
                } {
                    if ((index*index2)%2019==0){
                        flag = false;
                        min=0;
                        break;
                    }
                    if (min>(index*index2)%2019){
                        min=(index*index2)%2019;
                    }
                } if ((index*index2)%2019==0){
                        flag = false;
                        min=0;
                        break;
                    } (index*index2)%2019==0 (index*index2)%2019 (index*index2) index index2 2019 0 {
                        flag = false;
                        min=0;
                        break;
                    } flag = false flag false min=0 min 0 break; if (min>(index*index2)%2019){
                        min=(index*index2)%2019;
                    } min>(index*index2)%2019 min (index*index2)%2019 (index*index2) index index2 2019 {
                        min=(index*index2)%2019;
                    } min=(index*index2)%2019 min (index*index2)%2019 (index*index2) index index2 2019 System.out.println(min) System.out.println System.out System System.out min String[] args args public class Main {
    
    public static void main (String[] args){
        
      Scanner sc = new Scanner (System.in);
        
        long L = sc.nextLong();
        long R = sc.nextLong();
        
        if (R>=2019&&L<=2019){
            System.out.println(0);
        } else {
            long min = Long.MAX_VALUE;
            boolean flag = true;
            
            for (long index=L; index<R; index++){
                if (flag==false){
                    break;
                }
                for (long index2=index+1; index2<=R; index2++){
                    if ((index*index2)%2019==0){
                        flag = false;
                        min=0;
                        break;
                    }
                    if (min>(index*index2)%2019){
                        min=(index*index2)%2019;
                    }
                }
            }
            System.out.println(min);
        }
    }
} public class Main {
    
    public static void main (String[] args){
        
      Scanner sc = new Scanner (System.in);
        
        long L = sc.nextLong();
        long R = sc.nextLong();
        
        if (R>=2019&&L<=2019){
            System.out.println(0);
        } else {
            long min = Long.MAX_VALUE;
            boolean flag = true;
            
            for (long index=L; index<R; index++){
                if (flag==false){
                    break;
                }
                for (long index2=index+1; index2<=R; index2++){
                    if ((index*index2)%2019==0){
                        flag = false;
                        min=0;
                        break;
                    }
                    if (min>(index*index2)%2019){
                        min=(index*index2)%2019;
                    }
                }
            }
            System.out.println(min);
        }
    }
} Main
import java.util.Scanner;

public class Main {
    
    public static void main (String[] args){
        
      Scanner sc = new Scanner (System.in);
        
        long L = sc.nextLong();
        long R = sc.nextLong();
        
        if (R>=2019&&L<=2019){
            System.out.println(0);
        } else {
            long min = Long.MAX_VALUE;
            boolean flag = true;
            
            for (long index=L; index<R; index++){
                if (flag==false){
                    break;
                }
                for (long index2=index+1; index2<=R; index2++){
                    if ((index*index2)%2019==0){
                        flag = false;
                        min=0;
                        break;
                    }
                    if (min>(index*index2)%2019){
                        min=(index*index2)%2019;
                    }
                }
            }
            System.out.println(min);
        }
    }
}