import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		long L, R;
		L = sc.nextLong();
		R = sc.nextLong();

		long ans = 2019;
		if(L == 2019 || R == 2019) {
			System.out.println(0);
			return;
		}
		if(R - L >= 2019) {
			System.out.println(0);
			return;
		} else if(R - L < 2019) {
			for (long i = L; i < R; i++) {
				for (long j = L + 1; j <= R; j++) {
					long res = ((i * j) % 2019);
					ans = Math.min(ans, res);
				}
			}
		}

		System.out.println(ans);
	}
} import java.util.Scanner; Scanner java.util public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		long L, R;
		L = sc.nextLong();
		R = sc.nextLong();

		long ans = 2019;
		if(L == 2019 || R == 2019) {
			System.out.println(0);
			return;
		}
		if(R - L >= 2019) {
			System.out.println(0);
			return;
		} else if(R - L < 2019) {
			for (long i = L; i < R; i++) {
				for (long j = L + 1; j <= R; j++) {
					long res = ((i * j) % 2019);
					ans = Math.min(ans, res);
				}
			}
		}

		System.out.println(ans);
	}
} Main public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		long L, R;
		L = sc.nextLong();
		R = sc.nextLong();

		long ans = 2019;
		if(L == 2019 || R == 2019) {
			System.out.println(0);
			return;
		}
		if(R - L >= 2019) {
			System.out.println(0);
			return;
		} else if(R - L < 2019) {
			for (long i = L; i < R; i++) {
				for (long j = L + 1; j <= R; j++) {
					long res = ((i * j) % 2019);
					ans = Math.min(ans, res);
				}
			}
		}

		System.out.println(ans);
	} main {
		Scanner sc = new Scanner(System.in);
		long L, R;
		L = sc.nextLong();
		R = sc.nextLong();

		long ans = 2019;
		if(L == 2019 || R == 2019) {
			System.out.println(0);
			return;
		}
		if(R - L >= 2019) {
			System.out.println(0);
			return;
		} else if(R - L < 2019) {
			for (long i = L; i < R; i++) {
				for (long j = L + 1; j <= R; j++) {
					long res = ((i * j) % 2019);
					ans = Math.min(ans, res);
				}
			}
		}

		System.out.println(ans);
	} Scanner sc = new Scanner(System.in); sc new Scanner(System.in) long L L R; R L = sc.nextLong() L sc.nextLong() sc.nextLong sc R = sc.nextLong() R sc.nextLong() sc.nextLong sc long ans = 2019; ans 2019 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; if(R - L >= 2019) {
			System.out.println(0);
			return;
		} else if(R - L < 2019) {
			for (long i = L; i < R; i++) {
				for (long j = L + 1; j <= R; j++) {
					long res = ((i * j) % 2019);
					ans = Math.min(ans, res);
				}
			}
		} R - L >= 2019 R - L R L 2019 {
			System.out.println(0);
			return;
		} System.out.println(0) System.out.println System.out System System.out 0 return; if(R - L < 2019) {
			for (long i = L; i < R; i++) {
				for (long j = L + 1; j <= R; j++) {
					long res = ((i * j) % 2019);
					ans = Math.min(ans, res);
				}
			}
		} R - L < 2019 R - L R L 2019 {
			for (long i = L; i < R; i++) {
				for (long j = L + 1; j <= R; j++) {
					long res = ((i * j) % 2019);
					ans = Math.min(ans, res);
				}
			}
		} for (long i = L; i < R; i++) {
				for (long j = L + 1; j <= R; j++) {
					long res = ((i * j) % 2019);
					ans = Math.min(ans, res);
				}
			} long i = L; long i = L; i L i < R i R i++ i++ i {
				for (long j = L + 1; j <= R; j++) {
					long res = ((i * j) % 2019);
					ans = Math.min(ans, res);
				}
			} {
				for (long j = L + 1; j <= R; j++) {
					long res = ((i * j) % 2019);
					ans = Math.min(ans, res);
				}
			} for (long j = L + 1; j <= R; j++) {
					long res = ((i * j) % 2019);
					ans = Math.min(ans, res);
				} long j = L + 1; long j = L + 1; j L + 1 L 1 j <= R j R j++ j++ j {
					long res = ((i * j) % 2019);
					ans = Math.min(ans, res);
				} {
					long res = ((i * j) % 2019);
					ans = Math.min(ans, res);
				} long res = ((i * j) % 2019); res ((i * j) % 2019) (i * j) i j 2019 ans = Math.min(ans, res) ans Math.min(ans, res) Math.min Math ans res 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) {
		Scanner sc = new Scanner(System.in);
		long L, R;
		L = sc.nextLong();
		R = sc.nextLong();

		long ans = 2019;
		if(L == 2019 || R == 2019) {
			System.out.println(0);
			return;
		}
		if(R - L >= 2019) {
			System.out.println(0);
			return;
		} else if(R - L < 2019) {
			for (long i = L; i < R; i++) {
				for (long j = L + 1; j <= R; j++) {
					long res = ((i * j) % 2019);
					ans = Math.min(ans, res);
				}
			}
		}

		System.out.println(ans);
	}
} public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		long L, R;
		L = sc.nextLong();
		R = sc.nextLong();

		long ans = 2019;
		if(L == 2019 || R == 2019) {
			System.out.println(0);
			return;
		}
		if(R - L >= 2019) {
			System.out.println(0);
			return;
		} else if(R - L < 2019) {
			for (long i = L; i < R; i++) {
				for (long j = L + 1; j <= R; j++) {
					long res = ((i * j) % 2019);
					ans = Math.min(ans, res);
				}
			}
		}

		System.out.println(ans);
	}
} Main
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		long L, R;
		L = sc.nextLong();
		R = sc.nextLong();

		long ans = 2019;
		if(L == 2019 || R == 2019) {
			System.out.println(0);
			return;
		}
		if(R - L >= 2019) {
			System.out.println(0);
			return;
		} else if(R - L < 2019) {
			for (long i = L; i < R; i++) {
				for (long j = L + 1; j <= R; j++) {
					long res = ((i * j) % 2019);
					ans = Math.min(ans, res);
				}
			}
		}

		System.out.println(ans);
	}
}