import java.util.*;

public class Main
{
  public static void main(String[] args)
  {
    Scanner sc = new Scanner(System.in);
    long l, r;
	
    l = sc.nextLong();
    r = sc.nextLong();

    long min = (l*r)%2019;

    if(min == 0)
    {
        System.out.println(0);
        System.exit(0);
    }

    long tmp;
    /*
    if(l >= 2019){
        for(int i = 1; i<r-l+1; i++)
        {  
            tmp = (l+i)%2019;
            if(tmp==0){
                System.out.println(0);
                System.exit(0);
            }
            else if(min > tmp){
                min = tmp;
            }
        }
    }
    else{
    */
        for(int i = 0; i<r-l; i++){
            for(int j = 1; j < r-l+1; j++){
                tmp = ((l+i)*(l+j))%2019;
                if(tmp==0){
                    System.out.println(0);
                    System.exit(0);

                }
                else if(min > tmp){
                    min = tmp;
                }
            }
        }
    //}
    System.out.println(min);
  }
} import java.util.*; util.* java public class Main
{
  public static void main(String[] args)
  {
    Scanner sc = new Scanner(System.in);
    long l, r;
	
    l = sc.nextLong();
    r = sc.nextLong();

    long min = (l*r)%2019;

    if(min == 0)
    {
        System.out.println(0);
        System.exit(0);
    }

    long tmp;
    /*
    if(l >= 2019){
        for(int i = 1; i<r-l+1; i++)
        {  
            tmp = (l+i)%2019;
            if(tmp==0){
                System.out.println(0);
                System.exit(0);
            }
            else if(min > tmp){
                min = tmp;
            }
        }
    }
    else{
    */
        for(int i = 0; i<r-l; i++){
            for(int j = 1; j < r-l+1; j++){
                tmp = ((l+i)*(l+j))%2019;
                if(tmp==0){
                    System.out.println(0);
                    System.exit(0);

                }
                else if(min > tmp){
                    min = tmp;
                }
            }
        }
    //}
    System.out.println(min);
  }
} Main public static void main(String[] args)
  {
    Scanner sc = new Scanner(System.in);
    long l, r;
	
    l = sc.nextLong();
    r = sc.nextLong();

    long min = (l*r)%2019;

    if(min == 0)
    {
        System.out.println(0);
        System.exit(0);
    }

    long tmp;
    /*
    if(l >= 2019){
        for(int i = 1; i<r-l+1; i++)
        {  
            tmp = (l+i)%2019;
            if(tmp==0){
                System.out.println(0);
                System.exit(0);
            }
            else if(min > tmp){
                min = tmp;
            }
        }
    }
    else{
    */
        for(int i = 0; i<r-l; i++){
            for(int j = 1; j < r-l+1; j++){
                tmp = ((l+i)*(l+j))%2019;
                if(tmp==0){
                    System.out.println(0);
                    System.exit(0);

                }
                else if(min > tmp){
                    min = tmp;
                }
            }
        }
    //}
    System.out.println(min);
  } main {
    Scanner sc = new Scanner(System.in);
    long l, r;
	
    l = sc.nextLong();
    r = sc.nextLong();

    long min = (l*r)%2019;

    if(min == 0)
    {
        System.out.println(0);
        System.exit(0);
    }

    long tmp;
    /*
    if(l >= 2019){
        for(int i = 1; i<r-l+1; i++)
        {  
            tmp = (l+i)%2019;
            if(tmp==0){
                System.out.println(0);
                System.exit(0);
            }
            else if(min > tmp){
                min = tmp;
            }
        }
    }
    else{
    */
        for(int i = 0; i<r-l; i++){
            for(int j = 1; j < r-l+1; j++){
                tmp = ((l+i)*(l+j))%2019;
                if(tmp==0){
                    System.out.println(0);
                    System.exit(0);

                }
                else if(min > tmp){
                    min = tmp;
                }
            }
        }
    //}
    System.out.println(min);
  } Scanner sc = new Scanner(System.in); sc new Scanner(System.in) long l l r; r l = sc.nextLong() l sc.nextLong() sc.nextLong sc r = sc.nextLong() r sc.nextLong() sc.nextLong sc long min = (l*r)%2019; min (l*r)%2019 (l*r) l r 2019 if(min == 0)
    {
        System.out.println(0);
        System.exit(0);
    } min == 0 min 0 {
        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 long tmp; tmp for(int i = 0; i<r-l; i++){
            for(int j = 1; j < r-l+1; j++){
                tmp = ((l+i)*(l+j))%2019;
                if(tmp==0){
                    System.out.println(0);
                    System.exit(0);

                }
                else if(min > tmp){
                    min = tmp;
                }
            }
        } int i = 0; int i = 0; i 0 i<r-l i r-l r l i++ i++ i {
            for(int j = 1; j < r-l+1; j++){
                tmp = ((l+i)*(l+j))%2019;
                if(tmp==0){
                    System.out.println(0);
                    System.exit(0);

                }
                else if(min > tmp){
                    min = tmp;
                }
            }
        } {
            for(int j = 1; j < r-l+1; j++){
                tmp = ((l+i)*(l+j))%2019;
                if(tmp==0){
                    System.out.println(0);
                    System.exit(0);

                }
                else if(min > tmp){
                    min = tmp;
                }
            }
        } for(int j = 1; j < r-l+1; j++){
                tmp = ((l+i)*(l+j))%2019;
                if(tmp==0){
                    System.out.println(0);
                    System.exit(0);

                }
                else if(min > tmp){
                    min = tmp;
                }
            } int j = 1; int j = 1; j 1 j < r-l+1 j r-l+1 r-l r l 1 j++ j++ j {
                tmp = ((l+i)*(l+j))%2019;
                if(tmp==0){
                    System.out.println(0);
                    System.exit(0);

                }
                else if(min > tmp){
                    min = tmp;
                }
            } {
                tmp = ((l+i)*(l+j))%2019;
                if(tmp==0){
                    System.out.println(0);
                    System.exit(0);

                }
                else if(min > tmp){
                    min = tmp;
                }
            } tmp = ((l+i)*(l+j))%2019 tmp ((l+i)*(l+j))%2019 ((l+i)*(l+j)) (l+i) l i (l+j) l j 2019 if(tmp==0){
                    System.out.println(0);
                    System.exit(0);

                }
                else if(min > tmp){
                    min = tmp;
                } tmp==0 tmp 0 {
                    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 if(min > tmp){
                    min = tmp;
                } min > tmp min tmp {
                    min = tmp;
                } min = tmp min tmp 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, r;
	
    l = sc.nextLong();
    r = sc.nextLong();

    long min = (l*r)%2019;

    if(min == 0)
    {
        System.out.println(0);
        System.exit(0);
    }

    long tmp;
    /*
    if(l >= 2019){
        for(int i = 1; i<r-l+1; i++)
        {  
            tmp = (l+i)%2019;
            if(tmp==0){
                System.out.println(0);
                System.exit(0);
            }
            else if(min > tmp){
                min = tmp;
            }
        }
    }
    else{
    */
        for(int i = 0; i<r-l; i++){
            for(int j = 1; j < r-l+1; j++){
                tmp = ((l+i)*(l+j))%2019;
                if(tmp==0){
                    System.out.println(0);
                    System.exit(0);

                }
                else if(min > tmp){
                    min = tmp;
                }
            }
        }
    //}
    System.out.println(min);
  }
} public class Main
{
  public static void main(String[] args)
  {
    Scanner sc = new Scanner(System.in);
    long l, r;
	
    l = sc.nextLong();
    r = sc.nextLong();

    long min = (l*r)%2019;

    if(min == 0)
    {
        System.out.println(0);
        System.exit(0);
    }

    long tmp;
    /*
    if(l >= 2019){
        for(int i = 1; i<r-l+1; i++)
        {  
            tmp = (l+i)%2019;
            if(tmp==0){
                System.out.println(0);
                System.exit(0);
            }
            else if(min > tmp){
                min = tmp;
            }
        }
    }
    else{
    */
        for(int i = 0; i<r-l; i++){
            for(int j = 1; j < r-l+1; j++){
                tmp = ((l+i)*(l+j))%2019;
                if(tmp==0){
                    System.out.println(0);
                    System.exit(0);

                }
                else if(min > tmp){
                    min = tmp;
                }
            }
        }
    //}
    System.out.println(min);
  }
} Main
import java.util.*;

public class Main
{
  public static void main(String[] args)
  {
    Scanner sc = new Scanner(System.in);
    long l, r;
	
    l = sc.nextLong();
    r = sc.nextLong();

    long min = (l*r)%2019;

    if(min == 0)
    {
        System.out.println(0);
        System.exit(0);
    }

    long tmp;
    /*
    if(l >= 2019){
        for(int i = 1; i<r-l+1; i++)
        {  
            tmp = (l+i)%2019;
            if(tmp==0){
                System.out.println(0);
                System.exit(0);
            }
            else if(min > tmp){
                min = tmp;
            }
        }
    }
    else{
    */
        for(int i = 0; i<r-l; i++){
            for(int j = 1; j < r-l+1; j++){
                tmp = ((l+i)*(l+j))%2019;
                if(tmp==0){
                    System.out.println(0);
                    System.exit(0);

                }
                else if(min > tmp){
                    min = tmp;
                }
            }
        }
    //}
    System.out.println(min);
  }
}