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 (L%2019==0||R%2019==0) {
			System.out.println(0);
			return ;
		}
		if (L/2019!=R/2019) {
			System.out.println(0);
			return ;
		}
		int min = 2019;
		for (long i=L;i<R;i++) {
			for (long j=i+1;j<=R;j++) {
				int temp = (int) (((i%2019)*(j%2019))%2019);
				if (temp<min) {
					min = temp;
				}
			}
		}
		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 (L%2019==0||R%2019==0) {
			System.out.println(0);
			return ;
		}
		if (L/2019!=R/2019) {
			System.out.println(0);
			return ;
		}
		int min = 2019;
		for (long i=L;i<R;i++) {
			for (long j=i+1;j<=R;j++) {
				int temp = (int) (((i%2019)*(j%2019))%2019);
				if (temp<min) {
					min = temp;
				}
			}
		}
		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 (L%2019==0||R%2019==0) {
			System.out.println(0);
			return ;
		}
		if (L/2019!=R/2019) {
			System.out.println(0);
			return ;
		}
		int min = 2019;
		for (long i=L;i<R;i++) {
			for (long j=i+1;j<=R;j++) {
				int temp = (int) (((i%2019)*(j%2019))%2019);
				if (temp<min) {
					min = temp;
				}
			}
		}
		System.out.println(min);
	} main {
		Scanner sc = new Scanner(System.in);
		long L = sc.nextLong();
		long R = sc.nextLong();
		if (L%2019==0||R%2019==0) {
			System.out.println(0);
			return ;
		}
		if (L/2019!=R/2019) {
			System.out.println(0);
			return ;
		}
		int min = 2019;
		for (long i=L;i<R;i++) {
			for (long j=i+1;j<=R;j++) {
				int temp = (int) (((i%2019)*(j%2019))%2019);
				if (temp<min) {
					min = temp;
				}
			}
		}
		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 (L%2019==0||R%2019==0) {
			System.out.println(0);
			return ;
		} L%2019==0||R%2019==0 L%2019==0 L%2019 L 2019 0 R%2019==0 R%2019 R 2019 0 {
			System.out.println(0);
			return ;
		} System.out.println(0) System.out.println System.out System System.out 0 return ; if (L/2019!=R/2019) {
			System.out.println(0);
			return ;
		} 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 ; int min = 2019; min 2019 for (long i=L;i<R;i++) {
			for (long j=i+1;j<=R;j++) {
				int temp = (int) (((i%2019)*(j%2019))%2019);
				if (temp<min) {
					min = temp;
				}
			}
		} long i=L; long i=L; i L i<R i R i++ i++ i {
			for (long j=i+1;j<=R;j++) {
				int temp = (int) (((i%2019)*(j%2019))%2019);
				if (temp<min) {
					min = temp;
				}
			}
		} {
			for (long j=i+1;j<=R;j++) {
				int temp = (int) (((i%2019)*(j%2019))%2019);
				if (temp<min) {
					min = temp;
				}
			}
		} for (long j=i+1;j<=R;j++) {
				int temp = (int) (((i%2019)*(j%2019))%2019);
				if (temp<min) {
					min = temp;
				}
			} long j=i+1; long j=i+1; j i+1 i 1 j<=R j R j++ j++ j {
				int temp = (int) (((i%2019)*(j%2019))%2019);
				if (temp<min) {
					min = temp;
				}
			} {
				int temp = (int) (((i%2019)*(j%2019))%2019);
				if (temp<min) {
					min = temp;
				}
			} int temp = (int) (((i%2019)*(j%2019))%2019); temp (int) (((i%2019)*(j%2019))%2019) ((i%2019)*(j%2019)) (i%2019) i 2019 (j%2019) j 2019 2019 if (temp<min) {
					min = temp;
				} temp<min temp min {
					min = temp;
				} min = temp min temp 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 (L%2019==0||R%2019==0) {
			System.out.println(0);
			return ;
		}
		if (L/2019!=R/2019) {
			System.out.println(0);
			return ;
		}
		int min = 2019;
		for (long i=L;i<R;i++) {
			for (long j=i+1;j<=R;j++) {
				int temp = (int) (((i%2019)*(j%2019))%2019);
				if (temp<min) {
					min = temp;
				}
			}
		}
		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 (L%2019==0||R%2019==0) {
			System.out.println(0);
			return ;
		}
		if (L/2019!=R/2019) {
			System.out.println(0);
			return ;
		}
		int min = 2019;
		for (long i=L;i<R;i++) {
			for (long j=i+1;j<=R;j++) {
				int temp = (int) (((i%2019)*(j%2019))%2019);
				if (temp<min) {
					min = temp;
				}
			}
		}
		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 (L%2019==0||R%2019==0) {
			System.out.println(0);
			return ;
		}
		if (L/2019!=R/2019) {
			System.out.println(0);
			return ;
		}
		int min = 2019;
		for (long i=L;i<R;i++) {
			for (long j=i+1;j<=R;j++) {
				int temp = (int) (((i%2019)*(j%2019))%2019);
				if (temp<min) {
					min = temp;
				}
			}
		}
		System.out.println(min);
	}
}