import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collections;
import java.util.Comparator;
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner in = new Scanner(new BufferedReader(new InputStreamReader(System.in)));
		int l = in.nextInt();
		int r = in.nextInt();
		System.out.println(solve(l, r));
		in.close();
	}

	private static int solve(int l, int r) {
		int s = 2019;
		if (l % 2019 == 0)
			return 0;
		if ((l / 2019 + 1) * 2019 <= r)
			return 0;
		for (int i = l % 2019; i < r % 2019; i++)
			for (int j = i + 1; j <= r % 2019; j++)
				if (s > (i * j) % 2019)
					s = (i * j) % 2019;
		return s;
	}
} import java.io.BufferedReader; BufferedReader java.io import java.io.InputStreamReader; InputStreamReader java.io import java.util.ArrayList; ArrayList java.util import java.util.Arrays; Arrays java.util import java.util.Collections; Collections java.util import java.util.Comparator; Comparator java.util import java.util.Scanner; Scanner java.util public class Main {
	public static void main(String[] args) {
		Scanner in = new Scanner(new BufferedReader(new InputStreamReader(System.in)));
		int l = in.nextInt();
		int r = in.nextInt();
		System.out.println(solve(l, r));
		in.close();
	}

	private static int solve(int l, int r) {
		int s = 2019;
		if (l % 2019 == 0)
			return 0;
		if ((l / 2019 + 1) * 2019 <= r)
			return 0;
		for (int i = l % 2019; i < r % 2019; i++)
			for (int j = i + 1; j <= r % 2019; j++)
				if (s > (i * j) % 2019)
					s = (i * j) % 2019;
		return s;
	}
} Main public static void main(String[] args) {
		Scanner in = new Scanner(new BufferedReader(new InputStreamReader(System.in)));
		int l = in.nextInt();
		int r = in.nextInt();
		System.out.println(solve(l, r));
		in.close();
	} main {
		Scanner in = new Scanner(new BufferedReader(new InputStreamReader(System.in)));
		int l = in.nextInt();
		int r = in.nextInt();
		System.out.println(solve(l, r));
		in.close();
	} Scanner in = new Scanner(new BufferedReader(new InputStreamReader(System.in))); in new Scanner(new BufferedReader(new InputStreamReader(System.in))) int l = in.nextInt(); l in.nextInt() in.nextInt in int r = in.nextInt(); r in.nextInt() in.nextInt in System.out.println(solve(l, r)) System.out.println System.out System System.out solve(l, r) solve l r in.close() in.close in String[] args args private static int solve(int l, int r) {
		int s = 2019;
		if (l % 2019 == 0)
			return 0;
		if ((l / 2019 + 1) * 2019 <= r)
			return 0;
		for (int i = l % 2019; i < r % 2019; i++)
			for (int j = i + 1; j <= r % 2019; j++)
				if (s > (i * j) % 2019)
					s = (i * j) % 2019;
		return s;
	} solve {
		int s = 2019;
		if (l % 2019 == 0)
			return 0;
		if ((l / 2019 + 1) * 2019 <= r)
			return 0;
		for (int i = l % 2019; i < r % 2019; i++)
			for (int j = i + 1; j <= r % 2019; j++)
				if (s > (i * j) % 2019)
					s = (i * j) % 2019;
		return s;
	} int s = 2019; s 2019 if (l % 2019 == 0)
			return 0; l % 2019 == 0 l % 2019 l 2019 0 return 0; 0 if ((l / 2019 + 1) * 2019 <= r)
			return 0; (l / 2019 + 1) * 2019 <= r (l / 2019 + 1) * 2019 (l / 2019 + 1) l / 2019 l 2019 1 2019 r return 0; 0 for (int i = l % 2019; i < r % 2019; i++)
			for (int j = i + 1; j <= r % 2019; j++)
				if (s > (i * j) % 2019)
					s = (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 (s > (i * j) % 2019)
					s = (i * j) % 2019; for (int j = i + 1; j <= r % 2019; j++)
				if (s > (i * j) % 2019)
					s = (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 (s > (i * j) % 2019)
					s = (i * j) % 2019; if (s > (i * j) % 2019)
					s = (i * j) % 2019; s > (i * j) % 2019 s (i * j) % 2019 (i * j) i j 2019 s = (i * j) % 2019 s (i * j) % 2019 (i * j) i j 2019 return s; s int l l int r r public class Main {
	public static void main(String[] args) {
		Scanner in = new Scanner(new BufferedReader(new InputStreamReader(System.in)));
		int l = in.nextInt();
		int r = in.nextInt();
		System.out.println(solve(l, r));
		in.close();
	}

	private static int solve(int l, int r) {
		int s = 2019;
		if (l % 2019 == 0)
			return 0;
		if ((l / 2019 + 1) * 2019 <= r)
			return 0;
		for (int i = l % 2019; i < r % 2019; i++)
			for (int j = i + 1; j <= r % 2019; j++)
				if (s > (i * j) % 2019)
					s = (i * j) % 2019;
		return s;
	}
} public class Main {
	public static void main(String[] args) {
		Scanner in = new Scanner(new BufferedReader(new InputStreamReader(System.in)));
		int l = in.nextInt();
		int r = in.nextInt();
		System.out.println(solve(l, r));
		in.close();
	}

	private static int solve(int l, int r) {
		int s = 2019;
		if (l % 2019 == 0)
			return 0;
		if ((l / 2019 + 1) * 2019 <= r)
			return 0;
		for (int i = l % 2019; i < r % 2019; i++)
			for (int j = i + 1; j <= r % 2019; j++)
				if (s > (i * j) % 2019)
					s = (i * j) % 2019;
		return s;
	}
} Main
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collections;
import java.util.Comparator;
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner in = new Scanner(new BufferedReader(new InputStreamReader(System.in)));
		int l = in.nextInt();
		int r = in.nextInt();
		System.out.println(solve(l, r));
		in.close();
	}

	private static int solve(int l, int r) {
		int s = 2019;
		if (l % 2019 == 0)
			return 0;
		if ((l / 2019 + 1) * 2019 <= r)
			return 0;
		for (int i = l % 2019; i < r % 2019; i++)
			for (int j = i + 1; j <= r % 2019; j++)
				if (s > (i * j) % 2019)
					s = (i * j) % 2019;
		return s;
	}
}
