import java.io.FileNotFoundException;
import java.util.Scanner;

public class Main {
	public static void main(String[] args) throws FileNotFoundException {

		//    	File file = new File("src/in.txt");
		//    	Scanner sc = new Scanner(file);

		Scanner sc = new Scanner(System.in);

		int L = sc.nextInt();
		int R = sc.nextInt();

		if(R%2019==0||L%2019==0) {
			System.out.println("0");
			System.exit(0);
		}
		if((R-L)>=2018) {
			System.out.println("0");
			System.exit(0);
		}
		for(int i=L;i<=R;i++) {
			if(i%2019==0) {
				System.out.println("0");
				System.exit(0);
			}
		}
		int l = L%2019;
		int r = R%2019;
		int ans = 2018;
		for(int i=l;i<r;i++) {
			for(int j=i+1;j<=r;j++) {
				int tmp = (i*j)%2019;
				if(tmp<ans) {
					ans = tmp;
				}
			}
		}
		System.out.println(ans);
	}
} import java.io.FileNotFoundException; FileNotFoundException java.io import java.util.Scanner; Scanner java.util public class Main {
	public static void main(String[] args) throws FileNotFoundException {

		//    	File file = new File("src/in.txt");
		//    	Scanner sc = new Scanner(file);

		Scanner sc = new Scanner(System.in);

		int L = sc.nextInt();
		int R = sc.nextInt();

		if(R%2019==0||L%2019==0) {
			System.out.println("0");
			System.exit(0);
		}
		if((R-L)>=2018) {
			System.out.println("0");
			System.exit(0);
		}
		for(int i=L;i<=R;i++) {
			if(i%2019==0) {
				System.out.println("0");
				System.exit(0);
			}
		}
		int l = L%2019;
		int r = R%2019;
		int ans = 2018;
		for(int i=l;i<r;i++) {
			for(int j=i+1;j<=r;j++) {
				int tmp = (i*j)%2019;
				if(tmp<ans) {
					ans = tmp;
				}
			}
		}
		System.out.println(ans);
	}
} Main public static void main(String[] args) throws FileNotFoundException {

		//    	File file = new File("src/in.txt");
		//    	Scanner sc = new Scanner(file);

		Scanner sc = new Scanner(System.in);

		int L = sc.nextInt();
		int R = sc.nextInt();

		if(R%2019==0||L%2019==0) {
			System.out.println("0");
			System.exit(0);
		}
		if((R-L)>=2018) {
			System.out.println("0");
			System.exit(0);
		}
		for(int i=L;i<=R;i++) {
			if(i%2019==0) {
				System.out.println("0");
				System.exit(0);
			}
		}
		int l = L%2019;
		int r = R%2019;
		int ans = 2018;
		for(int i=l;i<r;i++) {
			for(int j=i+1;j<=r;j++) {
				int tmp = (i*j)%2019;
				if(tmp<ans) {
					ans = tmp;
				}
			}
		}
		System.out.println(ans);
	} main {

		//    	File file = new File("src/in.txt");
		//    	Scanner sc = new Scanner(file);

		Scanner sc = new Scanner(System.in);

		int L = sc.nextInt();
		int R = sc.nextInt();

		if(R%2019==0||L%2019==0) {
			System.out.println("0");
			System.exit(0);
		}
		if((R-L)>=2018) {
			System.out.println("0");
			System.exit(0);
		}
		for(int i=L;i<=R;i++) {
			if(i%2019==0) {
				System.out.println("0");
				System.exit(0);
			}
		}
		int l = L%2019;
		int r = R%2019;
		int ans = 2018;
		for(int i=l;i<r;i++) {
			for(int j=i+1;j<=r;j++) {
				int tmp = (i*j)%2019;
				if(tmp<ans) {
					ans = tmp;
				}
			}
		}
		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 if(R%2019==0||L%2019==0) {
			System.out.println("0");
			System.exit(0);
		} R%2019==0||L%2019==0 R%2019==0 R%2019 R 2019 0 L%2019==0 L%2019 L 2019 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((R-L)>=2018) {
			System.out.println("0");
			System.exit(0);
		} (R-L)>=2018 (R-L) R L 2018 {
			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 for(int i=L;i<=R;i++) {
			if(i%2019==0) {
				System.out.println("0");
				System.exit(0);
			}
		} int i=L; int i=L; i L i<=R i R i++ i++ i {
			if(i%2019==0) {
				System.out.println("0");
				System.exit(0);
			}
		} {
			if(i%2019==0) {
				System.out.println("0");
				System.exit(0);
			}
		} if(i%2019==0) {
				System.out.println("0");
				System.exit(0);
			} i%2019==0 i%2019 i 2019 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 int l = L%2019; l L%2019 L 2019 int r = R%2019; r R%2019 R 2019 int ans = 2018; ans 2018 for(int i=l;i<r;i++) {
			for(int j=i+1;j<=r;j++) {
				int tmp = (i*j)%2019;
				if(tmp<ans) {
					ans = tmp;
				}
			}
		} int i=l; int i=l; i l i<r i r i++ i++ i {
			for(int j=i+1;j<=r;j++) {
				int tmp = (i*j)%2019;
				if(tmp<ans) {
					ans = tmp;
				}
			}
		} {
			for(int j=i+1;j<=r;j++) {
				int tmp = (i*j)%2019;
				if(tmp<ans) {
					ans = tmp;
				}
			}
		} for(int j=i+1;j<=r;j++) {
				int tmp = (i*j)%2019;
				if(tmp<ans) {
					ans = tmp;
				}
			} int j=i+1; int j=i+1; j i+1 i 1 j<=r j r j++ j++ j {
				int tmp = (i*j)%2019;
				if(tmp<ans) {
					ans = tmp;
				}
			} {
				int tmp = (i*j)%2019;
				if(tmp<ans) {
					ans = tmp;
				}
			} int tmp = (i*j)%2019; tmp (i*j)%2019 (i*j) i j 2019 if(tmp<ans) {
					ans = tmp;
				} tmp<ans tmp ans {
					ans = tmp;
				} ans = tmp ans tmp System.out.println(ans) System.out.println System.out System System.out ans String[] args args public class Main {
	public static void main(String[] args) throws FileNotFoundException {

		//    	File file = new File("src/in.txt");
		//    	Scanner sc = new Scanner(file);

		Scanner sc = new Scanner(System.in);

		int L = sc.nextInt();
		int R = sc.nextInt();

		if(R%2019==0||L%2019==0) {
			System.out.println("0");
			System.exit(0);
		}
		if((R-L)>=2018) {
			System.out.println("0");
			System.exit(0);
		}
		for(int i=L;i<=R;i++) {
			if(i%2019==0) {
				System.out.println("0");
				System.exit(0);
			}
		}
		int l = L%2019;
		int r = R%2019;
		int ans = 2018;
		for(int i=l;i<r;i++) {
			for(int j=i+1;j<=r;j++) {
				int tmp = (i*j)%2019;
				if(tmp<ans) {
					ans = tmp;
				}
			}
		}
		System.out.println(ans);
	}
} public class Main {
	public static void main(String[] args) throws FileNotFoundException {

		//    	File file = new File("src/in.txt");
		//    	Scanner sc = new Scanner(file);

		Scanner sc = new Scanner(System.in);

		int L = sc.nextInt();
		int R = sc.nextInt();

		if(R%2019==0||L%2019==0) {
			System.out.println("0");
			System.exit(0);
		}
		if((R-L)>=2018) {
			System.out.println("0");
			System.exit(0);
		}
		for(int i=L;i<=R;i++) {
			if(i%2019==0) {
				System.out.println("0");
				System.exit(0);
			}
		}
		int l = L%2019;
		int r = R%2019;
		int ans = 2018;
		for(int i=l;i<r;i++) {
			for(int j=i+1;j<=r;j++) {
				int tmp = (i*j)%2019;
				if(tmp<ans) {
					ans = tmp;
				}
			}
		}
		System.out.println(ans);
	}
} Main
import java.io.FileNotFoundException;
import java.util.Scanner;

public class Main {
	public static void main(String[] args) throws FileNotFoundException {

		//    	File file = new File("src/in.txt");
		//    	Scanner sc = new Scanner(file);

		Scanner sc = new Scanner(System.in);

		int L = sc.nextInt();
		int R = sc.nextInt();

		if(R%2019==0||L%2019==0) {
			System.out.println("0");
			System.exit(0);
		}
		if((R-L)>=2018) {
			System.out.println("0");
			System.exit(0);
		}
		for(int i=L;i<=R;i++) {
			if(i%2019==0) {
				System.out.println("0");
				System.exit(0);
			}
		}
		int l = L%2019;
		int r = R%2019;
		int ans = 2018;
		for(int i=l;i<r;i++) {
			for(int j=i+1;j<=r;j++) {
				int tmp = (i*j)%2019;
				if(tmp<ans) {
					ans = tmp;
				}
			}
		}
		System.out.println(ans);
	}
}