import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		final int M = 2019;
		long l = sc.nextLong();
		long r = sc.nextLong();
		long lm = l % M;
		long rm = r % M;

		if (lm >= rm || r - l >= M - 1) {
			System.out.println(0);
			return;
		}

		long answer = 2018;
		for (long i = lm; i < rm; i++) {
			for (long j = i + 1; j <= rm; j++) {
				answer = Math.min(answer, (i * j) % M);
			}
		}
		System.out.println(answer);
	}
} import java.util.Scanner; Scanner java.util public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		final int M = 2019;
		long l = sc.nextLong();
		long r = sc.nextLong();
		long lm = l % M;
		long rm = r % M;

		if (lm >= rm || r - l >= M - 1) {
			System.out.println(0);
			return;
		}

		long answer = 2018;
		for (long i = lm; i < rm; i++) {
			for (long j = i + 1; j <= rm; j++) {
				answer = Math.min(answer, (i * j) % M);
			}
		}
		System.out.println(answer);
	}
} Main public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		final int M = 2019;
		long l = sc.nextLong();
		long r = sc.nextLong();
		long lm = l % M;
		long rm = r % M;

		if (lm >= rm || r - l >= M - 1) {
			System.out.println(0);
			return;
		}

		long answer = 2018;
		for (long i = lm; i < rm; i++) {
			for (long j = i + 1; j <= rm; j++) {
				answer = Math.min(answer, (i * j) % M);
			}
		}
		System.out.println(answer);
	} main {
		Scanner sc = new Scanner(System.in);
		final int M = 2019;
		long l = sc.nextLong();
		long r = sc.nextLong();
		long lm = l % M;
		long rm = r % M;

		if (lm >= rm || r - l >= M - 1) {
			System.out.println(0);
			return;
		}

		long answer = 2018;
		for (long i = lm; i < rm; i++) {
			for (long j = i + 1; j <= rm; j++) {
				answer = Math.min(answer, (i * j) % M);
			}
		}
		System.out.println(answer);
	} Scanner sc = new Scanner(System.in); sc new Scanner(System.in) final int M = 2019; M 2019 long l = sc.nextLong(); l sc.nextLong() sc.nextLong sc long r = sc.nextLong(); r sc.nextLong() sc.nextLong sc long lm = l % M; lm l % M l M long rm = r % M; rm r % M r M if (lm >= rm || r - l >= M - 1) {
			System.out.println(0);
			return;
		} lm >= rm || r - l >= M - 1 lm >= rm lm rm r - l >= M - 1 r - l r l M - 1 M 1 {
			System.out.println(0);
			return;
		} System.out.println(0) System.out.println System.out System System.out 0 return; long answer = 2018; answer 2018 for (long i = lm; i < rm; i++) {
			for (long j = i + 1; j <= rm; j++) {
				answer = Math.min(answer, (i * j) % M);
			}
		} long i = lm; long i = lm; i lm i < rm i rm i++ i++ i {
			for (long j = i + 1; j <= rm; j++) {
				answer = Math.min(answer, (i * j) % M);
			}
		} {
			for (long j = i + 1; j <= rm; j++) {
				answer = Math.min(answer, (i * j) % M);
			}
		} for (long j = i + 1; j <= rm; j++) {
				answer = Math.min(answer, (i * j) % M);
			} long j = i + 1; long j = i + 1; j i + 1 i 1 j <= rm j rm j++ j++ j {
				answer = Math.min(answer, (i * j) % M);
			} {
				answer = Math.min(answer, (i * j) % M);
			} answer = Math.min(answer, (i * j) % M) answer Math.min(answer, (i * j) % M) Math.min Math answer (i * j) % M (i * j) i j M System.out.println(answer) System.out.println System.out System System.out answer String[] args args public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		final int M = 2019;
		long l = sc.nextLong();
		long r = sc.nextLong();
		long lm = l % M;
		long rm = r % M;

		if (lm >= rm || r - l >= M - 1) {
			System.out.println(0);
			return;
		}

		long answer = 2018;
		for (long i = lm; i < rm; i++) {
			for (long j = i + 1; j <= rm; j++) {
				answer = Math.min(answer, (i * j) % M);
			}
		}
		System.out.println(answer);
	}
} public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		final int M = 2019;
		long l = sc.nextLong();
		long r = sc.nextLong();
		long lm = l % M;
		long rm = r % M;

		if (lm >= rm || r - l >= M - 1) {
			System.out.println(0);
			return;
		}

		long answer = 2018;
		for (long i = lm; i < rm; i++) {
			for (long j = i + 1; j <= rm; j++) {
				answer = Math.min(answer, (i * j) % M);
			}
		}
		System.out.println(answer);
	}
} Main
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		final int M = 2019;
		long l = sc.nextLong();
		long r = sc.nextLong();
		long lm = l % M;
		long rm = r % M;

		if (lm >= rm || r - l >= M - 1) {
			System.out.println(0);
			return;
		}

		long answer = 2018;
		for (long i = lm; i < rm; i++) {
			for (long j = i + 1; j <= rm; j++) {
				answer = Math.min(answer, (i * j) % M);
			}
		}
		System.out.println(answer);
	}
}
