import java.util.*;
class Main{
	public static void main(String[] args){
		Scanner sc=new Scanner(System.in);
		int L=sc.nextInt();
		int R=sc.nextInt();
		long min=0;
		if(L%2019==0||R%2019==0||L/2019<R/2019){
			System.out.println(0);
			return;
		}

		for(long i=L;i<=R;i++){
			for(long j=i+1;j<=R;j++){
				long a=(i*j)%2019;
				if((i==L&&j==L+1)||min>a){min=a;}
			}
		}
		System.out.println(min);
	}
} import java.util.*; util.* java class Main{
	public static void main(String[] args){
		Scanner sc=new Scanner(System.in);
		int L=sc.nextInt();
		int R=sc.nextInt();
		long min=0;
		if(L%2019==0||R%2019==0||L/2019<R/2019){
			System.out.println(0);
			return;
		}

		for(long i=L;i<=R;i++){
			for(long j=i+1;j<=R;j++){
				long a=(i*j)%2019;
				if((i==L&&j==L+1)||min>a){min=a;}
			}
		}
		System.out.println(min);
	}
} Main public static void main(String[] args){
		Scanner sc=new Scanner(System.in);
		int L=sc.nextInt();
		int R=sc.nextInt();
		long min=0;
		if(L%2019==0||R%2019==0||L/2019<R/2019){
			System.out.println(0);
			return;
		}

		for(long i=L;i<=R;i++){
			for(long j=i+1;j<=R;j++){
				long a=(i*j)%2019;
				if((i==L&&j==L+1)||min>a){min=a;}
			}
		}
		System.out.println(min);
	} main {
		Scanner sc=new Scanner(System.in);
		int L=sc.nextInt();
		int R=sc.nextInt();
		long min=0;
		if(L%2019==0||R%2019==0||L/2019<R/2019){
			System.out.println(0);
			return;
		}

		for(long i=L;i<=R;i++){
			for(long j=i+1;j<=R;j++){
				long a=(i*j)%2019;
				if((i==L&&j==L+1)||min>a){min=a;}
			}
		}
		System.out.println(min);
	} 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 min=0; min 0 if(L%2019==0||R%2019==0||L/2019<R/2019){
			System.out.println(0);
			return;
		} L%2019==0||R%2019==0||L/2019<R/2019 L%2019==0||R%2019==0||L/2019<R/2019 L%2019==0 L%2019 L 2019 0 R%2019==0 R%2019 R 2019 0 L/2019<R/2019 L/2019 L 2019 R/2019 R 2019 {
			System.out.println(0);
			return;
		} System.out.println(0) System.out.println System.out System System.out 0 return; for(long i=L;i<=R;i++){
			for(long j=i+1;j<=R;j++){
				long a=(i*j)%2019;
				if((i==L&&j==L+1)||min>a){min=a;}
			}
		} long i=L; long i=L; i L i<=R i R i++ i++ i {
			for(long j=i+1;j<=R;j++){
				long a=(i*j)%2019;
				if((i==L&&j==L+1)||min>a){min=a;}
			}
		} {
			for(long j=i+1;j<=R;j++){
				long a=(i*j)%2019;
				if((i==L&&j==L+1)||min>a){min=a;}
			}
		} for(long j=i+1;j<=R;j++){
				long a=(i*j)%2019;
				if((i==L&&j==L+1)||min>a){min=a;}
			} long j=i+1; long j=i+1; j i+1 i 1 j<=R j R j++ j++ j {
				long a=(i*j)%2019;
				if((i==L&&j==L+1)||min>a){min=a;}
			} {
				long a=(i*j)%2019;
				if((i==L&&j==L+1)||min>a){min=a;}
			} long a=(i*j)%2019; a (i*j)%2019 (i*j) i j 2019 if((i==L&&j==L+1)||min>a){min=a;} (i==L&&j==L+1)||min>a (i==L&&j==L+1) i==L i L j==L+1 j L+1 L 1 min>a min a {min=a;} min=a min a System.out.println(min) System.out.println System.out System System.out min String[] args args
import java.util.*;
class Main{
	public static void main(String[] args){
		Scanner sc=new Scanner(System.in);
		int L=sc.nextInt();
		int R=sc.nextInt();
		long min=0;
		if(L%2019==0||R%2019==0||L/2019<R/2019){
			System.out.println(0);
			return;
		}

		for(long i=L;i<=R;i++){
			for(long j=i+1;j<=R;j++){
				long a=(i*j)%2019;
				if((i==L&&j==L+1)||min>a){min=a;}
			}
		}
		System.out.println(min);
	}
}