import java.util.*;

public class Main {

	public static void main(String[] args) {
		// TODO Auto-generated method stub
		Scanner sc = new Scanner(System.in);
		long L = sc.nextLong();
		long R = sc.nextLong();
		long L2019 = L % 2019;
		long R2019 = R % 2019;
		
		if(L/2019 != R/2019 || L2019 == 0) {
			System.out.println(0);
			return;
		}
		
		long ans = Long.MAX_VALUE;
		
		for(long i = L2019; i <= R2019-1; i++) {
			for(long j = i+1; j<= R2019; j++) {
				ans = (ans < (i*j)%2019) ? ans : (i*j)%2019;
			}
		}
		
		System.out.println(ans);
	}

} import java.util.*; util.* java public class Main {

	public static void main(String[] args) {
		// TODO Auto-generated method stub
		Scanner sc = new Scanner(System.in);
		long L = sc.nextLong();
		long R = sc.nextLong();
		long L2019 = L % 2019;
		long R2019 = R % 2019;
		
		if(L/2019 != R/2019 || L2019 == 0) {
			System.out.println(0);
			return;
		}
		
		long ans = Long.MAX_VALUE;
		
		for(long i = L2019; i <= R2019-1; i++) {
			for(long j = i+1; j<= R2019; j++) {
				ans = (ans < (i*j)%2019) ? ans : (i*j)%2019;
			}
		}
		
		System.out.println(ans);
	}

} Main public static void main(String[] args) {
		// TODO Auto-generated method stub
		Scanner sc = new Scanner(System.in);
		long L = sc.nextLong();
		long R = sc.nextLong();
		long L2019 = L % 2019;
		long R2019 = R % 2019;
		
		if(L/2019 != R/2019 || L2019 == 0) {
			System.out.println(0);
			return;
		}
		
		long ans = Long.MAX_VALUE;
		
		for(long i = L2019; i <= R2019-1; i++) {
			for(long j = i+1; j<= R2019; j++) {
				ans = (ans < (i*j)%2019) ? ans : (i*j)%2019;
			}
		}
		
		System.out.println(ans);
	} main {
		// TODO Auto-generated method stub
		Scanner sc = new Scanner(System.in);
		long L = sc.nextLong();
		long R = sc.nextLong();
		long L2019 = L % 2019;
		long R2019 = R % 2019;
		
		if(L/2019 != R/2019 || L2019 == 0) {
			System.out.println(0);
			return;
		}
		
		long ans = Long.MAX_VALUE;
		
		for(long i = L2019; i <= R2019-1; i++) {
			for(long j = i+1; j<= R2019; j++) {
				ans = (ans < (i*j)%2019) ? ans : (i*j)%2019;
			}
		}
		
		System.out.println(ans);
	} 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 long L2019 = L % 2019; L2019 L % 2019 L 2019 long R2019 = R % 2019; R2019 R % 2019 R 2019 if(L/2019 != R/2019 || L2019 == 0) {
			System.out.println(0);
			return;
		} L/2019 != R/2019 || L2019 == 0 L/2019 != R/2019 L/2019 L 2019 R/2019 R 2019 L2019 == 0 L2019 0 {
			System.out.println(0);
			return;
		} System.out.println(0) System.out.println System.out System System.out 0 return; long ans = Long.MAX_VALUE; ans Long.MAX_VALUE Long Long.MAX_VALUE for(long i = L2019; i <= R2019-1; i++) {
			for(long j = i+1; j<= R2019; j++) {
				ans = (ans < (i*j)%2019) ? ans : (i*j)%2019;
			}
		} long i = L2019; long i = L2019; i L2019 i <= R2019-1 i R2019-1 R2019 1 i++ i++ i {
			for(long j = i+1; j<= R2019; j++) {
				ans = (ans < (i*j)%2019) ? ans : (i*j)%2019;
			}
		} {
			for(long j = i+1; j<= R2019; j++) {
				ans = (ans < (i*j)%2019) ? ans : (i*j)%2019;
			}
		} for(long j = i+1; j<= R2019; j++) {
				ans = (ans < (i*j)%2019) ? ans : (i*j)%2019;
			} long j = i+1; long j = i+1; j i+1 i 1 j<= R2019 j R2019 j++ j++ j {
				ans = (ans < (i*j)%2019) ? ans : (i*j)%2019;
			} {
				ans = (ans < (i*j)%2019) ? ans : (i*j)%2019;
			} ans = (ans < (i*j)%2019) ? ans : (i*j)%2019 ans (ans < (i*j)%2019) ? ans : (i*j)%2019 (ans < (i*j)%2019) ans (i*j)%2019 (i*j) i j 2019 ans (i*j)%2019 (i*j) i j 2019 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) {
		// TODO Auto-generated method stub
		Scanner sc = new Scanner(System.in);
		long L = sc.nextLong();
		long R = sc.nextLong();
		long L2019 = L % 2019;
		long R2019 = R % 2019;
		
		if(L/2019 != R/2019 || L2019 == 0) {
			System.out.println(0);
			return;
		}
		
		long ans = Long.MAX_VALUE;
		
		for(long i = L2019; i <= R2019-1; i++) {
			for(long j = i+1; j<= R2019; j++) {
				ans = (ans < (i*j)%2019) ? ans : (i*j)%2019;
			}
		}
		
		System.out.println(ans);
	}

} public class Main {

	public static void main(String[] args) {
		// TODO Auto-generated method stub
		Scanner sc = new Scanner(System.in);
		long L = sc.nextLong();
		long R = sc.nextLong();
		long L2019 = L % 2019;
		long R2019 = R % 2019;
		
		if(L/2019 != R/2019 || L2019 == 0) {
			System.out.println(0);
			return;
		}
		
		long ans = Long.MAX_VALUE;
		
		for(long i = L2019; i <= R2019-1; i++) {
			for(long j = i+1; j<= R2019; j++) {
				ans = (ans < (i*j)%2019) ? ans : (i*j)%2019;
			}
		}
		
		System.out.println(ans);
	}

} Main
import java.util.*;

public class Main {

	public static void main(String[] args) {
		// TODO Auto-generated method stub
		Scanner sc = new Scanner(System.in);
		long L = sc.nextLong();
		long R = sc.nextLong();
		long L2019 = L % 2019;
		long R2019 = R % 2019;
		
		if(L/2019 != R/2019 || L2019 == 0) {
			System.out.println(0);
			return;
		}
		
		long ans = Long.MAX_VALUE;
		
		for(long i = L2019; i <= R2019-1; i++) {
			for(long j = i+1; j<= R2019; j++) {
				ans = (ans < (i*j)%2019) ? ans : (i*j)%2019;
			}
		}
		
		System.out.println(ans);
	}

}
