import java.io.*;
import java.math.*;
import java.util.*;
public class Main {

	public static void main(String[] args) {
		Scanner input = new Scanner(System.in);
		long L = input.nextLong();
		long R = input.nextLong();
		long mod = 2019;
		long TotalDistance = R-L;
		long LDistance = mod-L%mod; //Above lowerbound
		long RDistance = R%mod; //Below upperbound
		TotalDistance-=LDistance;
		TotalDistance-=RDistance;
		if (TotalDistance>=2019) System.out.println(0);
		else {
			long ans = 2018;
			for (long l = L; l <= R;l++) {
				for (long r = l+1; r <= R; r++) {
					long curans = l*r;
					curans%=mod;
					ans = Math.min(ans, curans);
					//if (ans==curans) System.out.println(l+" "+r);
				}
			}
			System.out.println(ans);
		}
	}
} import java.io.*; io.* java import java.math.*; math.* java import java.util.*; util.* java public class Main {

	public static void main(String[] args) {
		Scanner input = new Scanner(System.in);
		long L = input.nextLong();
		long R = input.nextLong();
		long mod = 2019;
		long TotalDistance = R-L;
		long LDistance = mod-L%mod; //Above lowerbound
		long RDistance = R%mod; //Below upperbound
		TotalDistance-=LDistance;
		TotalDistance-=RDistance;
		if (TotalDistance>=2019) System.out.println(0);
		else {
			long ans = 2018;
			for (long l = L; l <= R;l++) {
				for (long r = l+1; r <= R; r++) {
					long curans = l*r;
					curans%=mod;
					ans = Math.min(ans, curans);
					//if (ans==curans) System.out.println(l+" "+r);
				}
			}
			System.out.println(ans);
		}
	}
} Main public static void main(String[] args) {
		Scanner input = new Scanner(System.in);
		long L = input.nextLong();
		long R = input.nextLong();
		long mod = 2019;
		long TotalDistance = R-L;
		long LDistance = mod-L%mod; //Above lowerbound
		long RDistance = R%mod; //Below upperbound
		TotalDistance-=LDistance;
		TotalDistance-=RDistance;
		if (TotalDistance>=2019) System.out.println(0);
		else {
			long ans = 2018;
			for (long l = L; l <= R;l++) {
				for (long r = l+1; r <= R; r++) {
					long curans = l*r;
					curans%=mod;
					ans = Math.min(ans, curans);
					//if (ans==curans) System.out.println(l+" "+r);
				}
			}
			System.out.println(ans);
		}
	} main {
		Scanner input = new Scanner(System.in);
		long L = input.nextLong();
		long R = input.nextLong();
		long mod = 2019;
		long TotalDistance = R-L;
		long LDistance = mod-L%mod; //Above lowerbound
		long RDistance = R%mod; //Below upperbound
		TotalDistance-=LDistance;
		TotalDistance-=RDistance;
		if (TotalDistance>=2019) System.out.println(0);
		else {
			long ans = 2018;
			for (long l = L; l <= R;l++) {
				for (long r = l+1; r <= R; r++) {
					long curans = l*r;
					curans%=mod;
					ans = Math.min(ans, curans);
					//if (ans==curans) System.out.println(l+" "+r);
				}
			}
			System.out.println(ans);
		}
	} Scanner input = new Scanner(System.in); input new Scanner(System.in) long L = input.nextLong(); L input.nextLong() input.nextLong input long R = input.nextLong(); R input.nextLong() input.nextLong input long mod = 2019; mod 2019 long TotalDistance = R-L; TotalDistance R-L R L long LDistance = mod-L%mod; LDistance mod-L%mod mod L%mod L mod long RDistance = R%mod; RDistance R%mod R mod TotalDistance-=LDistance TotalDistance LDistance TotalDistance-=RDistance TotalDistance RDistance if (TotalDistance>=2019) System.out.println(0);
		else {
			long ans = 2018;
			for (long l = L; l <= R;l++) {
				for (long r = l+1; r <= R; r++) {
					long curans = l*r;
					curans%=mod;
					ans = Math.min(ans, curans);
					//if (ans==curans) System.out.println(l+" "+r);
				}
			}
			System.out.println(ans);
		} TotalDistance>=2019 TotalDistance 2019 System.out.println(0) System.out.println System.out System System.out 0 {
			long ans = 2018;
			for (long l = L; l <= R;l++) {
				for (long r = l+1; r <= R; r++) {
					long curans = l*r;
					curans%=mod;
					ans = Math.min(ans, curans);
					//if (ans==curans) System.out.println(l+" "+r);
				}
			}
			System.out.println(ans);
		} long ans = 2018; ans 2018 for (long l = L; l <= R;l++) {
				for (long r = l+1; r <= R; r++) {
					long curans = l*r;
					curans%=mod;
					ans = Math.min(ans, curans);
					//if (ans==curans) System.out.println(l+" "+r);
				}
			} long l = L; long l = L; l L l <= R l R l++ l++ l {
				for (long r = l+1; r <= R; r++) {
					long curans = l*r;
					curans%=mod;
					ans = Math.min(ans, curans);
					//if (ans==curans) System.out.println(l+" "+r);
				}
			} {
				for (long r = l+1; r <= R; r++) {
					long curans = l*r;
					curans%=mod;
					ans = Math.min(ans, curans);
					//if (ans==curans) System.out.println(l+" "+r);
				}
			} for (long r = l+1; r <= R; r++) {
					long curans = l*r;
					curans%=mod;
					ans = Math.min(ans, curans);
					//if (ans==curans) System.out.println(l+" "+r);
				} long r = l+1; long r = l+1; r l+1 l 1 r <= R r R r++ r++ r {
					long curans = l*r;
					curans%=mod;
					ans = Math.min(ans, curans);
					//if (ans==curans) System.out.println(l+" "+r);
				} {
					long curans = l*r;
					curans%=mod;
					ans = Math.min(ans, curans);
					//if (ans==curans) System.out.println(l+" "+r);
				} long curans = l*r; curans l*r l r curans%=mod curans mod ans = Math.min(ans, curans) ans Math.min(ans, curans) Math.min Math ans curans 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 input = new Scanner(System.in);
		long L = input.nextLong();
		long R = input.nextLong();
		long mod = 2019;
		long TotalDistance = R-L;
		long LDistance = mod-L%mod; //Above lowerbound
		long RDistance = R%mod; //Below upperbound
		TotalDistance-=LDistance;
		TotalDistance-=RDistance;
		if (TotalDistance>=2019) System.out.println(0);
		else {
			long ans = 2018;
			for (long l = L; l <= R;l++) {
				for (long r = l+1; r <= R; r++) {
					long curans = l*r;
					curans%=mod;
					ans = Math.min(ans, curans);
					//if (ans==curans) System.out.println(l+" "+r);
				}
			}
			System.out.println(ans);
		}
	}
} public class Main {

	public static void main(String[] args) {
		Scanner input = new Scanner(System.in);
		long L = input.nextLong();
		long R = input.nextLong();
		long mod = 2019;
		long TotalDistance = R-L;
		long LDistance = mod-L%mod; //Above lowerbound
		long RDistance = R%mod; //Below upperbound
		TotalDistance-=LDistance;
		TotalDistance-=RDistance;
		if (TotalDistance>=2019) System.out.println(0);
		else {
			long ans = 2018;
			for (long l = L; l <= R;l++) {
				for (long r = l+1; r <= R; r++) {
					long curans = l*r;
					curans%=mod;
					ans = Math.min(ans, curans);
					//if (ans==curans) System.out.println(l+" "+r);
				}
			}
			System.out.println(ans);
		}
	}
} Main
import java.io.*;
import java.math.*;
import java.util.*;
public class Main {

	public static void main(String[] args) {
		Scanner input = new Scanner(System.in);
		long L = input.nextLong();
		long R = input.nextLong();
		long mod = 2019;
		long TotalDistance = R-L;
		long LDistance = mod-L%mod; //Above lowerbound
		long RDistance = R%mod; //Below upperbound
		TotalDistance-=LDistance;
		TotalDistance-=RDistance;
		if (TotalDistance>=2019) System.out.println(0);
		else {
			long ans = 2018;
			for (long l = L; l <= R;l++) {
				for (long r = l+1; r <= R; r++) {
					long curans = l*r;
					curans%=mod;
					ans = Math.min(ans, curans);
					//if (ans==curans) System.out.println(l+" "+r);
				}
			}
			System.out.println(ans);
		}
	}
}