import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int div = 2019;
		long L = Integer.parseInt(sc.next());
		long R = Integer.parseInt(sc.next());
		long l = L / div;
		long r = R / div;
		if (l != r) {
			System.out.println(0);
			sc.close();
			return;
		}
		long diff = -1;
		for (long i = L + 1; i <= R; i++) {
			for (long j = L; j < i; j++) {
				long currentDiff = ((i % div) * (j % div)) % div;
				if (diff == -1) {
					diff = currentDiff;
				} else if (diff > currentDiff) {
					diff = currentDiff;
				}
			}
		}
		System.out.println(diff);
		sc.close();
	}
} import java.util.Scanner; Scanner java.util public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int div = 2019;
		long L = Integer.parseInt(sc.next());
		long R = Integer.parseInt(sc.next());
		long l = L / div;
		long r = R / div;
		if (l != r) {
			System.out.println(0);
			sc.close();
			return;
		}
		long diff = -1;
		for (long i = L + 1; i <= R; i++) {
			for (long j = L; j < i; j++) {
				long currentDiff = ((i % div) * (j % div)) % div;
				if (diff == -1) {
					diff = currentDiff;
				} else if (diff > currentDiff) {
					diff = currentDiff;
				}
			}
		}
		System.out.println(diff);
		sc.close();
	}
} Main public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int div = 2019;
		long L = Integer.parseInt(sc.next());
		long R = Integer.parseInt(sc.next());
		long l = L / div;
		long r = R / div;
		if (l != r) {
			System.out.println(0);
			sc.close();
			return;
		}
		long diff = -1;
		for (long i = L + 1; i <= R; i++) {
			for (long j = L; j < i; j++) {
				long currentDiff = ((i % div) * (j % div)) % div;
				if (diff == -1) {
					diff = currentDiff;
				} else if (diff > currentDiff) {
					diff = currentDiff;
				}
			}
		}
		System.out.println(diff);
		sc.close();
	} main {
		Scanner sc = new Scanner(System.in);
		int div = 2019;
		long L = Integer.parseInt(sc.next());
		long R = Integer.parseInt(sc.next());
		long l = L / div;
		long r = R / div;
		if (l != r) {
			System.out.println(0);
			sc.close();
			return;
		}
		long diff = -1;
		for (long i = L + 1; i <= R; i++) {
			for (long j = L; j < i; j++) {
				long currentDiff = ((i % div) * (j % div)) % div;
				if (diff == -1) {
					diff = currentDiff;
				} else if (diff > currentDiff) {
					diff = currentDiff;
				}
			}
		}
		System.out.println(diff);
		sc.close();
	} Scanner sc = new Scanner(System.in); sc new Scanner(System.in) int div = 2019; div 2019 long L = Integer.parseInt(sc.next()); L Integer.parseInt(sc.next()) Integer.parseInt Integer sc.next() sc.next sc long R = Integer.parseInt(sc.next()); R Integer.parseInt(sc.next()) Integer.parseInt Integer sc.next() sc.next sc long l = L / div; l L / div L div long r = R / div; r R / div R div if (l != r) {
			System.out.println(0);
			sc.close();
			return;
		} l != r l r {
			System.out.println(0);
			sc.close();
			return;
		} System.out.println(0) System.out.println System.out System System.out 0 sc.close() sc.close sc return; long diff = -1; diff -1 1 for (long i = L + 1; i <= R; i++) {
			for (long j = L; j < i; j++) {
				long currentDiff = ((i % div) * (j % div)) % div;
				if (diff == -1) {
					diff = currentDiff;
				} else if (diff > currentDiff) {
					diff = currentDiff;
				}
			}
		} long i = L + 1; long i = L + 1; i L + 1 L 1 i <= R i R i++ i++ i {
			for (long j = L; j < i; j++) {
				long currentDiff = ((i % div) * (j % div)) % div;
				if (diff == -1) {
					diff = currentDiff;
				} else if (diff > currentDiff) {
					diff = currentDiff;
				}
			}
		} {
			for (long j = L; j < i; j++) {
				long currentDiff = ((i % div) * (j % div)) % div;
				if (diff == -1) {
					diff = currentDiff;
				} else if (diff > currentDiff) {
					diff = currentDiff;
				}
			}
		} for (long j = L; j < i; j++) {
				long currentDiff = ((i % div) * (j % div)) % div;
				if (diff == -1) {
					diff = currentDiff;
				} else if (diff > currentDiff) {
					diff = currentDiff;
				}
			} long j = L; long j = L; j L j < i j i j++ j++ j {
				long currentDiff = ((i % div) * (j % div)) % div;
				if (diff == -1) {
					diff = currentDiff;
				} else if (diff > currentDiff) {
					diff = currentDiff;
				}
			} {
				long currentDiff = ((i % div) * (j % div)) % div;
				if (diff == -1) {
					diff = currentDiff;
				} else if (diff > currentDiff) {
					diff = currentDiff;
				}
			} long currentDiff = ((i % div) * (j % div)) % div; currentDiff ((i % div) * (j % div)) % div ((i % div) * (j % div)) (i % div) i div (j % div) j div div if (diff == -1) {
					diff = currentDiff;
				} else if (diff > currentDiff) {
					diff = currentDiff;
				} diff == -1 diff -1 1 {
					diff = currentDiff;
				} diff = currentDiff diff currentDiff if (diff > currentDiff) {
					diff = currentDiff;
				} diff > currentDiff diff currentDiff {
					diff = currentDiff;
				} diff = currentDiff diff currentDiff System.out.println(diff) System.out.println System.out System System.out diff sc.close() sc.close sc String[] args args public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int div = 2019;
		long L = Integer.parseInt(sc.next());
		long R = Integer.parseInt(sc.next());
		long l = L / div;
		long r = R / div;
		if (l != r) {
			System.out.println(0);
			sc.close();
			return;
		}
		long diff = -1;
		for (long i = L + 1; i <= R; i++) {
			for (long j = L; j < i; j++) {
				long currentDiff = ((i % div) * (j % div)) % div;
				if (diff == -1) {
					diff = currentDiff;
				} else if (diff > currentDiff) {
					diff = currentDiff;
				}
			}
		}
		System.out.println(diff);
		sc.close();
	}
} public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int div = 2019;
		long L = Integer.parseInt(sc.next());
		long R = Integer.parseInt(sc.next());
		long l = L / div;
		long r = R / div;
		if (l != r) {
			System.out.println(0);
			sc.close();
			return;
		}
		long diff = -1;
		for (long i = L + 1; i <= R; i++) {
			for (long j = L; j < i; j++) {
				long currentDiff = ((i % div) * (j % div)) % div;
				if (diff == -1) {
					diff = currentDiff;
				} else if (diff > currentDiff) {
					diff = currentDiff;
				}
			}
		}
		System.out.println(diff);
		sc.close();
	}
} Main
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int div = 2019;
		long L = Integer.parseInt(sc.next());
		long R = Integer.parseInt(sc.next());
		long l = L / div;
		long r = R / div;
		if (l != r) {
			System.out.println(0);
			sc.close();
			return;
		}
		long diff = -1;
		for (long i = L + 1; i <= R; i++) {
			for (long j = L; j < i; j++) {
				long currentDiff = ((i % div) * (j % div)) % div;
				if (diff == -1) {
					diff = currentDiff;
				} else if (diff > currentDiff) {
					diff = currentDiff;
				}
			}
		}
		System.out.println(diff);
		sc.close();
	}
}
