import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int l = sc.nextInt();
		int r = sc.nextInt();
		long min = Long.MAX_VALUE;
		int diff = r - l;
		int start = l;
		int end = r;
		if (diff >= 2019) {
			for (int i = 0; i < 2019; i++) {
				if (min > (l + i) % 2019L) {
					start = l + i;
					min = (l + i) % 2019L;
				}
			}
			
			end = start + 2019;
		}
		
		min = Long.MAX_VALUE;
		for (int i = start; i <= end; i++) {
			for (int j = start; j <= end; j++) {
				if (i == j) {
					continue;
				}
				long tmp = (i % 2019L * j % 2019L) % 2019;
				if (min > tmp) {
					min = tmp;
				}
			}
		}
		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);
		int l = sc.nextInt();
		int r = sc.nextInt();
		long min = Long.MAX_VALUE;
		int diff = r - l;
		int start = l;
		int end = r;
		if (diff >= 2019) {
			for (int i = 0; i < 2019; i++) {
				if (min > (l + i) % 2019L) {
					start = l + i;
					min = (l + i) % 2019L;
				}
			}
			
			end = start + 2019;
		}
		
		min = Long.MAX_VALUE;
		for (int i = start; i <= end; i++) {
			for (int j = start; j <= end; j++) {
				if (i == j) {
					continue;
				}
				long tmp = (i % 2019L * j % 2019L) % 2019;
				if (min > tmp) {
					min = tmp;
				}
			}
		}
		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 = Long.MAX_VALUE;
		int diff = r - l;
		int start = l;
		int end = r;
		if (diff >= 2019) {
			for (int i = 0; i < 2019; i++) {
				if (min > (l + i) % 2019L) {
					start = l + i;
					min = (l + i) % 2019L;
				}
			}
			
			end = start + 2019;
		}
		
		min = Long.MAX_VALUE;
		for (int i = start; i <= end; i++) {
			for (int j = start; j <= end; j++) {
				if (i == j) {
					continue;
				}
				long tmp = (i % 2019L * j % 2019L) % 2019;
				if (min > tmp) {
					min = tmp;
				}
			}
		}
		System.out.println(min);
	} main {
		Scanner sc = new Scanner(System.in);
		int l = sc.nextInt();
		int r = sc.nextInt();
		long min = Long.MAX_VALUE;
		int diff = r - l;
		int start = l;
		int end = r;
		if (diff >= 2019) {
			for (int i = 0; i < 2019; i++) {
				if (min > (l + i) % 2019L) {
					start = l + i;
					min = (l + i) % 2019L;
				}
			}
			
			end = start + 2019;
		}
		
		min = Long.MAX_VALUE;
		for (int i = start; i <= end; i++) {
			for (int j = start; j <= end; j++) {
				if (i == j) {
					continue;
				}
				long tmp = (i % 2019L * j % 2019L) % 2019;
				if (min > tmp) {
					min = tmp;
				}
			}
		}
		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 = Long.MAX_VALUE; min Long.MAX_VALUE Long Long.MAX_VALUE int diff = r - l; diff r - l r l int start = l; start l int end = r; end r if (diff >= 2019) {
			for (int i = 0; i < 2019; i++) {
				if (min > (l + i) % 2019L) {
					start = l + i;
					min = (l + i) % 2019L;
				}
			}
			
			end = start + 2019;
		} diff >= 2019 diff 2019 {
			for (int i = 0; i < 2019; i++) {
				if (min > (l + i) % 2019L) {
					start = l + i;
					min = (l + i) % 2019L;
				}
			}
			
			end = start + 2019;
		} for (int i = 0; i < 2019; i++) {
				if (min > (l + i) % 2019L) {
					start = l + i;
					min = (l + i) % 2019L;
				}
			} int i = 0; int i = 0; i 0 i < 2019 i 2019 i++ i++ i {
				if (min > (l + i) % 2019L) {
					start = l + i;
					min = (l + i) % 2019L;
				}
			} {
				if (min > (l + i) % 2019L) {
					start = l + i;
					min = (l + i) % 2019L;
				}
			} if (min > (l + i) % 2019L) {
					start = l + i;
					min = (l + i) % 2019L;
				} min > (l + i) % 2019L min (l + i) % 2019L (l + i) l i 2019L {
					start = l + i;
					min = (l + i) % 2019L;
				} start = l + i start l + i l i min = (l + i) % 2019L min (l + i) % 2019L (l + i) l i 2019L end = start + 2019 end start + 2019 start 2019 min = Long.MAX_VALUE min Long.MAX_VALUE Long Long.MAX_VALUE for (int i = start; i <= end; i++) {
			for (int j = start; j <= end; j++) {
				if (i == j) {
					continue;
				}
				long tmp = (i % 2019L * j % 2019L) % 2019;
				if (min > tmp) {
					min = tmp;
				}
			}
		} int i = start; int i = start; i start i <= end i end i++ i++ i {
			for (int j = start; j <= end; j++) {
				if (i == j) {
					continue;
				}
				long tmp = (i % 2019L * j % 2019L) % 2019;
				if (min > tmp) {
					min = tmp;
				}
			}
		} {
			for (int j = start; j <= end; j++) {
				if (i == j) {
					continue;
				}
				long tmp = (i % 2019L * j % 2019L) % 2019;
				if (min > tmp) {
					min = tmp;
				}
			}
		} for (int j = start; j <= end; j++) {
				if (i == j) {
					continue;
				}
				long tmp = (i % 2019L * j % 2019L) % 2019;
				if (min > tmp) {
					min = tmp;
				}
			} int j = start; int j = start; j start j <= end j end j++ j++ j {
				if (i == j) {
					continue;
				}
				long tmp = (i % 2019L * j % 2019L) % 2019;
				if (min > tmp) {
					min = tmp;
				}
			} {
				if (i == j) {
					continue;
				}
				long tmp = (i % 2019L * j % 2019L) % 2019;
				if (min > tmp) {
					min = tmp;
				}
			} if (i == j) {
					continue;
				} i == j i j {
					continue;
				} continue; long tmp = (i % 2019L * j % 2019L) % 2019; tmp (i % 2019L * j % 2019L) % 2019 (i % 2019L * j % 2019L) i % 2019L * j i % 2019L i 2019L j 2019L 2019 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);
		int l = sc.nextInt();
		int r = sc.nextInt();
		long min = Long.MAX_VALUE;
		int diff = r - l;
		int start = l;
		int end = r;
		if (diff >= 2019) {
			for (int i = 0; i < 2019; i++) {
				if (min > (l + i) % 2019L) {
					start = l + i;
					min = (l + i) % 2019L;
				}
			}
			
			end = start + 2019;
		}
		
		min = Long.MAX_VALUE;
		for (int i = start; i <= end; i++) {
			for (int j = start; j <= end; j++) {
				if (i == j) {
					continue;
				}
				long tmp = (i % 2019L * j % 2019L) % 2019;
				if (min > tmp) {
					min = tmp;
				}
			}
		}
		System.out.println(min);
	}
} public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int l = sc.nextInt();
		int r = sc.nextInt();
		long min = Long.MAX_VALUE;
		int diff = r - l;
		int start = l;
		int end = r;
		if (diff >= 2019) {
			for (int i = 0; i < 2019; i++) {
				if (min > (l + i) % 2019L) {
					start = l + i;
					min = (l + i) % 2019L;
				}
			}
			
			end = start + 2019;
		}
		
		min = Long.MAX_VALUE;
		for (int i = start; i <= end; i++) {
			for (int j = start; j <= end; j++) {
				if (i == j) {
					continue;
				}
				long tmp = (i % 2019L * j % 2019L) % 2019;
				if (min > tmp) {
					min = tmp;
				}
			}
		}
		System.out.println(min);
	}
} Main
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int l = sc.nextInt();
		int r = sc.nextInt();
		long min = Long.MAX_VALUE;
		int diff = r - l;
		int start = l;
		int end = r;
		if (diff >= 2019) {
			for (int i = 0; i < 2019; i++) {
				if (min > (l + i) % 2019L) {
					start = l + i;
					min = (l + i) % 2019L;
				}
			}
			
			end = start + 2019;
		}
		
		min = Long.MAX_VALUE;
		for (int i = start; i <= end; i++) {
			for (int j = start; j <= end; j++) {
				if (i == j) {
					continue;
				}
				long tmp = (i % 2019L * j % 2019L) % 2019;
				if (min > tmp) {
					min = tmp;
				}
			}
		}
		System.out.println(min);
	}
}
