import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		try (Scanner s = new Scanner(System.in)) {
			final int L = s.nextInt();
			final int R = s.nextInt();

			if (R - L >= 2019) {
				System.out.println(0);
			} else {
				int ret = 2019;
				for (int i = L % 2019; i < R % 2019; i++) {
					for (int j = i + 1; j <= R % 2019; j++) {
						if ((i * j) % 2019 < ret) {
							ret = (i * j) % 2019;
						}
					}
				}
				System.out.println(ret);
			}
		}
	}
} import java.util.Scanner; Scanner java.util public class Main {
	public static void main(String[] args) {
		try (Scanner s = new Scanner(System.in)) {
			final int L = s.nextInt();
			final int R = s.nextInt();

			if (R - L >= 2019) {
				System.out.println(0);
			} else {
				int ret = 2019;
				for (int i = L % 2019; i < R % 2019; i++) {
					for (int j = i + 1; j <= R % 2019; j++) {
						if ((i * j) % 2019 < ret) {
							ret = (i * j) % 2019;
						}
					}
				}
				System.out.println(ret);
			}
		}
	}
} Main public static void main(String[] args) {
		try (Scanner s = new Scanner(System.in)) {
			final int L = s.nextInt();
			final int R = s.nextInt();

			if (R - L >= 2019) {
				System.out.println(0);
			} else {
				int ret = 2019;
				for (int i = L % 2019; i < R % 2019; i++) {
					for (int j = i + 1; j <= R % 2019; j++) {
						if ((i * j) % 2019 < ret) {
							ret = (i * j) % 2019;
						}
					}
				}
				System.out.println(ret);
			}
		}
	} main {
		try (Scanner s = new Scanner(System.in)) {
			final int L = s.nextInt();
			final int R = s.nextInt();

			if (R - L >= 2019) {
				System.out.println(0);
			} else {
				int ret = 2019;
				for (int i = L % 2019; i < R % 2019; i++) {
					for (int j = i + 1; j <= R % 2019; j++) {
						if ((i * j) % 2019 < ret) {
							ret = (i * j) % 2019;
						}
					}
				}
				System.out.println(ret);
			}
		}
	} try (Scanner s = new Scanner(System.in)) {
			final int L = s.nextInt();
			final int R = s.nextInt();

			if (R - L >= 2019) {
				System.out.println(0);
			} else {
				int ret = 2019;
				for (int i = L % 2019; i < R % 2019; i++) {
					for (int j = i + 1; j <= R % 2019; j++) {
						if ((i * j) % 2019 < ret) {
							ret = (i * j) % 2019;
						}
					}
				}
				System.out.println(ret);
			}
		} {
			final int L = s.nextInt();
			final int R = s.nextInt();

			if (R - L >= 2019) {
				System.out.println(0);
			} else {
				int ret = 2019;
				for (int i = L % 2019; i < R % 2019; i++) {
					for (int j = i + 1; j <= R % 2019; j++) {
						if ((i * j) % 2019 < ret) {
							ret = (i * j) % 2019;
						}
					}
				}
				System.out.println(ret);
			}
		} Scanner s = new Scanner(System.in) Scanner s = new Scanner(System.in) new Scanner(System.in) final int L = s.nextInt(); L s.nextInt() s.nextInt s final int R = s.nextInt(); R s.nextInt() s.nextInt s if (R - L >= 2019) {
				System.out.println(0);
			} else {
				int ret = 2019;
				for (int i = L % 2019; i < R % 2019; i++) {
					for (int j = i + 1; j <= R % 2019; j++) {
						if ((i * j) % 2019 < ret) {
							ret = (i * j) % 2019;
						}
					}
				}
				System.out.println(ret);
			} R - L >= 2019 R - L R L 2019 {
				System.out.println(0);
			} System.out.println(0) System.out.println System.out System System.out 0 {
				int ret = 2019;
				for (int i = L % 2019; i < R % 2019; i++) {
					for (int j = i + 1; j <= R % 2019; j++) {
						if ((i * j) % 2019 < ret) {
							ret = (i * j) % 2019;
						}
					}
				}
				System.out.println(ret);
			} int ret = 2019; ret 2019 for (int i = L % 2019; i < R % 2019; i++) {
					for (int j = i + 1; j <= R % 2019; j++) {
						if ((i * j) % 2019 < ret) {
							ret = (i * j) % 2019;
						}
					}
				} int i = L % 2019; int i = L % 2019; i L % 2019 L 2019 i < R % 2019 i R % 2019 R 2019 i++ i++ i {
					for (int j = i + 1; j <= R % 2019; j++) {
						if ((i * j) % 2019 < ret) {
							ret = (i * j) % 2019;
						}
					}
				} {
					for (int j = i + 1; j <= R % 2019; j++) {
						if ((i * j) % 2019 < ret) {
							ret = (i * j) % 2019;
						}
					}
				} for (int j = i + 1; j <= R % 2019; j++) {
						if ((i * j) % 2019 < ret) {
							ret = (i * j) % 2019;
						}
					} int j = i + 1; int j = i + 1; j i + 1 i 1 j <= R % 2019 j R % 2019 R 2019 j++ j++ j {
						if ((i * j) % 2019 < ret) {
							ret = (i * j) % 2019;
						}
					} {
						if ((i * j) % 2019 < ret) {
							ret = (i * j) % 2019;
						}
					} if ((i * j) % 2019 < ret) {
							ret = (i * j) % 2019;
						} (i * j) % 2019 < ret (i * j) % 2019 (i * j) i j 2019 ret {
							ret = (i * j) % 2019;
						} ret = (i * j) % 2019 ret (i * j) % 2019 (i * j) i j 2019 System.out.println(ret) System.out.println System.out System System.out ret String[] args args public class Main {
	public static void main(String[] args) {
		try (Scanner s = new Scanner(System.in)) {
			final int L = s.nextInt();
			final int R = s.nextInt();

			if (R - L >= 2019) {
				System.out.println(0);
			} else {
				int ret = 2019;
				for (int i = L % 2019; i < R % 2019; i++) {
					for (int j = i + 1; j <= R % 2019; j++) {
						if ((i * j) % 2019 < ret) {
							ret = (i * j) % 2019;
						}
					}
				}
				System.out.println(ret);
			}
		}
	}
} public class Main {
	public static void main(String[] args) {
		try (Scanner s = new Scanner(System.in)) {
			final int L = s.nextInt();
			final int R = s.nextInt();

			if (R - L >= 2019) {
				System.out.println(0);
			} else {
				int ret = 2019;
				for (int i = L % 2019; i < R % 2019; i++) {
					for (int j = i + 1; j <= R % 2019; j++) {
						if ((i * j) % 2019 < ret) {
							ret = (i * j) % 2019;
						}
					}
				}
				System.out.println(ret);
			}
		}
	}
} Main
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		try (Scanner s = new Scanner(System.in)) {
			final int L = s.nextInt();
			final int R = s.nextInt();

			if (R - L >= 2019) {
				System.out.println(0);
			} else {
				int ret = 2019;
				for (int i = L % 2019; i < R % 2019; i++) {
					for (int j = i + 1; j <= R % 2019; j++) {
						if ((i * j) % 2019 < ret) {
							ret = (i * j) % 2019;
						}
					}
				}
				System.out.println(ret);
			}
		}
	}
}
