
import java.util.HashSet;
import java.util.Scanner;
import java.util.Set;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int m = 2019;
		int l = sc.nextInt();
		int r = sc.nextInt();
		
		int lm = l % m;
		int rm = r % m;
		int ld = l / m;
		int rd = r / m;		
		int minl = Integer.MAX_VALUE;
		
		boolean isLap = rd -ld > 0;
		if( lm == 0 || rm==0 || isLap ) {
			minl = 0;
		}else {
			for( int i=lm ; i< rm ; i++ ) {
				for( int j=lm+1 ; j<= rm ; j++ ) {
					int tmp=(i*j)%m;
					if(  minl > tmp ) {
						minl = tmp;
					}
				}
			}
		}
		
		System.out.println(minl);
	}
} import java.util.HashSet; HashSet java.util import java.util.Scanner; Scanner java.util import java.util.Set; Set java.util public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int m = 2019;
		int l = sc.nextInt();
		int r = sc.nextInt();
		
		int lm = l % m;
		int rm = r % m;
		int ld = l / m;
		int rd = r / m;		
		int minl = Integer.MAX_VALUE;
		
		boolean isLap = rd -ld > 0;
		if( lm == 0 || rm==0 || isLap ) {
			minl = 0;
		}else {
			for( int i=lm ; i< rm ; i++ ) {
				for( int j=lm+1 ; j<= rm ; j++ ) {
					int tmp=(i*j)%m;
					if(  minl > tmp ) {
						minl = tmp;
					}
				}
			}
		}
		
		System.out.println(minl);
	}
} Main public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int m = 2019;
		int l = sc.nextInt();
		int r = sc.nextInt();
		
		int lm = l % m;
		int rm = r % m;
		int ld = l / m;
		int rd = r / m;		
		int minl = Integer.MAX_VALUE;
		
		boolean isLap = rd -ld > 0;
		if( lm == 0 || rm==0 || isLap ) {
			minl = 0;
		}else {
			for( int i=lm ; i< rm ; i++ ) {
				for( int j=lm+1 ; j<= rm ; j++ ) {
					int tmp=(i*j)%m;
					if(  minl > tmp ) {
						minl = tmp;
					}
				}
			}
		}
		
		System.out.println(minl);
	} main {
		Scanner sc = new Scanner(System.in);
		int m = 2019;
		int l = sc.nextInt();
		int r = sc.nextInt();
		
		int lm = l % m;
		int rm = r % m;
		int ld = l / m;
		int rd = r / m;		
		int minl = Integer.MAX_VALUE;
		
		boolean isLap = rd -ld > 0;
		if( lm == 0 || rm==0 || isLap ) {
			minl = 0;
		}else {
			for( int i=lm ; i< rm ; i++ ) {
				for( int j=lm+1 ; j<= rm ; j++ ) {
					int tmp=(i*j)%m;
					if(  minl > tmp ) {
						minl = tmp;
					}
				}
			}
		}
		
		System.out.println(minl);
	} Scanner sc = new Scanner(System.in); sc new Scanner(System.in) int m = 2019; m 2019 int l = sc.nextInt(); l sc.nextInt() sc.nextInt sc int r = sc.nextInt(); r sc.nextInt() sc.nextInt sc int lm = l % m; lm l % m l m int rm = r % m; rm r % m r m int ld = l / m; ld l / m l m int rd = r / m; rd r / m r m int minl = Integer.MAX_VALUE; minl Integer.MAX_VALUE Integer Integer.MAX_VALUE boolean isLap = rd -ld > 0; isLap rd -ld > 0 rd -ld rd ld 0 if( lm == 0 || rm==0 || isLap ) {
			minl = 0;
		}else {
			for( int i=lm ; i< rm ; i++ ) {
				for( int j=lm+1 ; j<= rm ; j++ ) {
					int tmp=(i*j)%m;
					if(  minl > tmp ) {
						minl = tmp;
					}
				}
			}
		} lm == 0 || rm==0 || isLap lm == 0 || rm==0 || isLap lm == 0 lm 0 rm==0 rm 0 isLap {
			minl = 0;
		} minl = 0 minl 0 {
			for( int i=lm ; i< rm ; i++ ) {
				for( int j=lm+1 ; j<= rm ; j++ ) {
					int tmp=(i*j)%m;
					if(  minl > tmp ) {
						minl = tmp;
					}
				}
			}
		} for( int i=lm ; i< rm ; i++ ) {
				for( int j=lm+1 ; j<= rm ; j++ ) {
					int tmp=(i*j)%m;
					if(  minl > tmp ) {
						minl = tmp;
					}
				}
			} int i=lm ; int i=lm ; i lm i< rm i rm i++ i++ i {
				for( int j=lm+1 ; j<= rm ; j++ ) {
					int tmp=(i*j)%m;
					if(  minl > tmp ) {
						minl = tmp;
					}
				}
			} {
				for( int j=lm+1 ; j<= rm ; j++ ) {
					int tmp=(i*j)%m;
					if(  minl > tmp ) {
						minl = tmp;
					}
				}
			} for( int j=lm+1 ; j<= rm ; j++ ) {
					int tmp=(i*j)%m;
					if(  minl > tmp ) {
						minl = tmp;
					}
				} int j=lm+1 ; int j=lm+1 ; j lm+1 lm 1 j<= rm j rm j++ j++ j {
					int tmp=(i*j)%m;
					if(  minl > tmp ) {
						minl = tmp;
					}
				} {
					int tmp=(i*j)%m;
					if(  minl > tmp ) {
						minl = tmp;
					}
				} int tmp=(i*j)%m; tmp (i*j)%m (i*j) i j m if(  minl > tmp ) {
						minl = tmp;
					} minl > tmp minl tmp {
						minl = tmp;
					} minl = tmp minl tmp System.out.println(minl) System.out.println System.out System System.out minl String[] args args public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int m = 2019;
		int l = sc.nextInt();
		int r = sc.nextInt();
		
		int lm = l % m;
		int rm = r % m;
		int ld = l / m;
		int rd = r / m;		
		int minl = Integer.MAX_VALUE;
		
		boolean isLap = rd -ld > 0;
		if( lm == 0 || rm==0 || isLap ) {
			minl = 0;
		}else {
			for( int i=lm ; i< rm ; i++ ) {
				for( int j=lm+1 ; j<= rm ; j++ ) {
					int tmp=(i*j)%m;
					if(  minl > tmp ) {
						minl = tmp;
					}
				}
			}
		}
		
		System.out.println(minl);
	}
} public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int m = 2019;
		int l = sc.nextInt();
		int r = sc.nextInt();
		
		int lm = l % m;
		int rm = r % m;
		int ld = l / m;
		int rd = r / m;		
		int minl = Integer.MAX_VALUE;
		
		boolean isLap = rd -ld > 0;
		if( lm == 0 || rm==0 || isLap ) {
			minl = 0;
		}else {
			for( int i=lm ; i< rm ; i++ ) {
				for( int j=lm+1 ; j<= rm ; j++ ) {
					int tmp=(i*j)%m;
					if(  minl > tmp ) {
						minl = tmp;
					}
				}
			}
		}
		
		System.out.println(minl);
	}
} Main

import java.util.HashSet;
import java.util.Scanner;
import java.util.Set;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int m = 2019;
		int l = sc.nextInt();
		int r = sc.nextInt();
		
		int lm = l % m;
		int rm = r % m;
		int ld = l / m;
		int rd = r / m;		
		int minl = Integer.MAX_VALUE;
		
		boolean isLap = rd -ld > 0;
		if( lm == 0 || rm==0 || isLap ) {
			minl = 0;
		}else {
			for( int i=lm ; i< rm ; i++ ) {
				for( int j=lm+1 ; j<= rm ; j++ ) {
					int tmp=(i*j)%m;
					if(  minl > tmp ) {
						minl = tmp;
					}
				}
			}
		}
		
		System.out.println(minl);
	}
}
