import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		long l = sc.nextLong();
		long r = sc.nextLong();
		if (2019 <= r - l) {
			System.out.println(0);
			return;
		}
		long m = 0;
		long min = 2019l;
		long calc = 0;
		for (long i = l; i < r; i++) {
			m = i * i;
			for (long j = i + 1; j <= r; j++) {
				m += i;
				calc = m % 2019;
				if (calc < min) {
					min = calc;
				}
			}
		}

		System.out.println(min);
	}
} import java.util.Scanner; Scanner java.util public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		long l = sc.nextLong();
		long r = sc.nextLong();
		if (2019 <= r - l) {
			System.out.println(0);
			return;
		}
		long m = 0;
		long min = 2019l;
		long calc = 0;
		for (long i = l; i < r; i++) {
			m = i * i;
			for (long j = i + 1; j <= r; j++) {
				m += i;
				calc = m % 2019;
				if (calc < min) {
					min = calc;
				}
			}
		}

		System.out.println(min);
	}
} Main public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		long l = sc.nextLong();
		long r = sc.nextLong();
		if (2019 <= r - l) {
			System.out.println(0);
			return;
		}
		long m = 0;
		long min = 2019l;
		long calc = 0;
		for (long i = l; i < r; i++) {
			m = i * i;
			for (long j = i + 1; j <= r; j++) {
				m += i;
				calc = m % 2019;
				if (calc < min) {
					min = calc;
				}
			}
		}

		System.out.println(min);
	} main {
		Scanner sc = new Scanner(System.in);
		long l = sc.nextLong();
		long r = sc.nextLong();
		if (2019 <= r - l) {
			System.out.println(0);
			return;
		}
		long m = 0;
		long min = 2019l;
		long calc = 0;
		for (long i = l; i < r; i++) {
			m = i * i;
			for (long j = i + 1; j <= r; j++) {
				m += i;
				calc = m % 2019;
				if (calc < min) {
					min = calc;
				}
			}
		}

		System.out.println(min);
	} Scanner sc = new Scanner(System.in); sc new Scanner(System.in) long l = sc.nextLong(); l sc.nextLong() sc.nextLong sc long r = sc.nextLong(); r sc.nextLong() sc.nextLong sc if (2019 <= r - l) {
			System.out.println(0);
			return;
		} 2019 <= r - l 2019 r - l r l {
			System.out.println(0);
			return;
		} System.out.println(0) System.out.println System.out System System.out 0 return; long m = 0; m 0 long min = 2019l; min 2019l long calc = 0; calc 0 for (long i = l; i < r; i++) {
			m = i * i;
			for (long j = i + 1; j <= r; j++) {
				m += i;
				calc = m % 2019;
				if (calc < min) {
					min = calc;
				}
			}
		} long i = l; long i = l; i l i < r i r i++ i++ i {
			m = i * i;
			for (long j = i + 1; j <= r; j++) {
				m += i;
				calc = m % 2019;
				if (calc < min) {
					min = calc;
				}
			}
		} {
			m = i * i;
			for (long j = i + 1; j <= r; j++) {
				m += i;
				calc = m % 2019;
				if (calc < min) {
					min = calc;
				}
			}
		} m = i * i m i * i i i for (long j = i + 1; j <= r; j++) {
				m += i;
				calc = m % 2019;
				if (calc < min) {
					min = calc;
				}
			} long j = i + 1; long j = i + 1; j i + 1 i 1 j <= r j r j++ j++ j {
				m += i;
				calc = m % 2019;
				if (calc < min) {
					min = calc;
				}
			} {
				m += i;
				calc = m % 2019;
				if (calc < min) {
					min = calc;
				}
			} m += i m i calc = m % 2019 calc m % 2019 m 2019 if (calc < min) {
					min = calc;
				} calc < min calc min {
					min = calc;
				} min = calc min calc System.out.println(min) System.out.println System.out System System.out min String[] args args public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		long l = sc.nextLong();
		long r = sc.nextLong();
		if (2019 <= r - l) {
			System.out.println(0);
			return;
		}
		long m = 0;
		long min = 2019l;
		long calc = 0;
		for (long i = l; i < r; i++) {
			m = i * i;
			for (long j = i + 1; j <= r; j++) {
				m += i;
				calc = m % 2019;
				if (calc < min) {
					min = calc;
				}
			}
		}

		System.out.println(min);
	}
} public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		long l = sc.nextLong();
		long r = sc.nextLong();
		if (2019 <= r - l) {
			System.out.println(0);
			return;
		}
		long m = 0;
		long min = 2019l;
		long calc = 0;
		for (long i = l; i < r; i++) {
			m = i * i;
			for (long j = i + 1; j <= r; j++) {
				m += i;
				calc = m % 2019;
				if (calc < min) {
					min = calc;
				}
			}
		}

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

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		long l = sc.nextLong();
		long r = sc.nextLong();
		if (2019 <= r - l) {
			System.out.println(0);
			return;
		}
		long m = 0;
		long min = 2019l;
		long calc = 0;
		for (long i = l; i < r; i++) {
			m = i * i;
			for (long j = i + 1; j <= r; j++) {
				m += i;
				calc = m % 2019;
				if (calc < min) {
					min = calc;
				}
			}
		}

		System.out.println(min);
	}
}
