import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;

public class Main {

    public static void main(String[] args) {
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        try {
            String str = br.readLine();
            String input[] = str.split(" ");
            int L = Integer.valueOf(input[0]);
            int R = Integer.valueOf(input[1]);
            
            int result = 2018;

          if(R-L >2019){
            R = L+2019;
          }
          if(L > 2019 && L/2019 == R/2019){
            L %= 2019;
            R %= 2019;
          }

            for(int i = L; i<R; i++) {
				if(i%2019 == 0 || result == 0){
                  result = 0;
                  break;
                }
              for(int j = i+1; j<=R; j++) {
                  int N = i* j;
                    if( N % 2019 < result && N % 2019 > 0 ) {
                        result = N % 2019;
                    } else if(N%2019 == 0){
                      result = N % 2019;
                      break;
                    }
                }
            }
            System.out.println(result);
            
            
        }catch(IOException e) {
            
        }
    }

} import java.io.BufferedReader; BufferedReader java.io import java.io.IOException; IOException java.io import java.io.InputStreamReader; InputStreamReader java.io public class Main {

    public static void main(String[] args) {
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        try {
            String str = br.readLine();
            String input[] = str.split(" ");
            int L = Integer.valueOf(input[0]);
            int R = Integer.valueOf(input[1]);
            
            int result = 2018;

          if(R-L >2019){
            R = L+2019;
          }
          if(L > 2019 && L/2019 == R/2019){
            L %= 2019;
            R %= 2019;
          }

            for(int i = L; i<R; i++) {
				if(i%2019 == 0 || result == 0){
                  result = 0;
                  break;
                }
              for(int j = i+1; j<=R; j++) {
                  int N = i* j;
                    if( N % 2019 < result && N % 2019 > 0 ) {
                        result = N % 2019;
                    } else if(N%2019 == 0){
                      result = N % 2019;
                      break;
                    }
                }
            }
            System.out.println(result);
            
            
        }catch(IOException e) {
            
        }
    }

} Main public static void main(String[] args) {
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        try {
            String str = br.readLine();
            String input[] = str.split(" ");
            int L = Integer.valueOf(input[0]);
            int R = Integer.valueOf(input[1]);
            
            int result = 2018;

          if(R-L >2019){
            R = L+2019;
          }
          if(L > 2019 && L/2019 == R/2019){
            L %= 2019;
            R %= 2019;
          }

            for(int i = L; i<R; i++) {
				if(i%2019 == 0 || result == 0){
                  result = 0;
                  break;
                }
              for(int j = i+1; j<=R; j++) {
                  int N = i* j;
                    if( N % 2019 < result && N % 2019 > 0 ) {
                        result = N % 2019;
                    } else if(N%2019 == 0){
                      result = N % 2019;
                      break;
                    }
                }
            }
            System.out.println(result);
            
            
        }catch(IOException e) {
            
        }
    } main {
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        try {
            String str = br.readLine();
            String input[] = str.split(" ");
            int L = Integer.valueOf(input[0]);
            int R = Integer.valueOf(input[1]);
            
            int result = 2018;

          if(R-L >2019){
            R = L+2019;
          }
          if(L > 2019 && L/2019 == R/2019){
            L %= 2019;
            R %= 2019;
          }

            for(int i = L; i<R; i++) {
				if(i%2019 == 0 || result == 0){
                  result = 0;
                  break;
                }
              for(int j = i+1; j<=R; j++) {
                  int N = i* j;
                    if( N % 2019 < result && N % 2019 > 0 ) {
                        result = N % 2019;
                    } else if(N%2019 == 0){
                      result = N % 2019;
                      break;
                    }
                }
            }
            System.out.println(result);
            
            
        }catch(IOException e) {
            
        }
    } BufferedReader br = new BufferedReader(new InputStreamReader(System.in)); br new BufferedReader(new InputStreamReader(System.in)) try {
            String str = br.readLine();
            String input[] = str.split(" ");
            int L = Integer.valueOf(input[0]);
            int R = Integer.valueOf(input[1]);
            
            int result = 2018;

          if(R-L >2019){
            R = L+2019;
          }
          if(L > 2019 && L/2019 == R/2019){
            L %= 2019;
            R %= 2019;
          }

            for(int i = L; i<R; i++) {
				if(i%2019 == 0 || result == 0){
                  result = 0;
                  break;
                }
              for(int j = i+1; j<=R; j++) {
                  int N = i* j;
                    if( N % 2019 < result && N % 2019 > 0 ) {
                        result = N % 2019;
                    } else if(N%2019 == 0){
                      result = N % 2019;
                      break;
                    }
                }
            }
            System.out.println(result);
            
            
        }catch(IOException e) {
            
        } catch(IOException e) {
            
        } IOException e {
            
        } {
            String str = br.readLine();
            String input[] = str.split(" ");
            int L = Integer.valueOf(input[0]);
            int R = Integer.valueOf(input[1]);
            
            int result = 2018;

          if(R-L >2019){
            R = L+2019;
          }
          if(L > 2019 && L/2019 == R/2019){
            L %= 2019;
            R %= 2019;
          }

            for(int i = L; i<R; i++) {
				if(i%2019 == 0 || result == 0){
                  result = 0;
                  break;
                }
              for(int j = i+1; j<=R; j++) {
                  int N = i* j;
                    if( N % 2019 < result && N % 2019 > 0 ) {
                        result = N % 2019;
                    } else if(N%2019 == 0){
                      result = N % 2019;
                      break;
                    }
                }
            }
            System.out.println(result);
            
            
        } String str = br.readLine(); str br.readLine() br.readLine br String input[] = str.split(" "); input str.split(" ") str.split str " " int L = Integer.valueOf(input[0]); L Integer.valueOf(input[0]) Integer.valueOf Integer input[0] input 0 int R = Integer.valueOf(input[1]); R Integer.valueOf(input[1]) Integer.valueOf Integer input[1] input 1 int result = 2018; result 2018 if(R-L >2019){
            R = L+2019;
          } R-L >2019 R-L R L 2019 {
            R = L+2019;
          } R = L+2019 R L+2019 L 2019 if(L > 2019 && L/2019 == R/2019){
            L %= 2019;
            R %= 2019;
          } L > 2019 && L/2019 == R/2019 L > 2019 L 2019 L/2019 == R/2019 L/2019 L 2019 R/2019 R 2019 {
            L %= 2019;
            R %= 2019;
          } L %= 2019 L 2019 R %= 2019 R 2019 for(int i = L; i<R; i++) {
				if(i%2019 == 0 || result == 0){
                  result = 0;
                  break;
                }
              for(int j = i+1; j<=R; j++) {
                  int N = i* j;
                    if( N % 2019 < result && N % 2019 > 0 ) {
                        result = N % 2019;
                    } else if(N%2019 == 0){
                      result = N % 2019;
                      break;
                    }
                }
            } int i = L; int i = L; i L i<R i R i++ i++ i {
				if(i%2019 == 0 || result == 0){
                  result = 0;
                  break;
                }
              for(int j = i+1; j<=R; j++) {
                  int N = i* j;
                    if( N % 2019 < result && N % 2019 > 0 ) {
                        result = N % 2019;
                    } else if(N%2019 == 0){
                      result = N % 2019;
                      break;
                    }
                }
            } {
				if(i%2019 == 0 || result == 0){
                  result = 0;
                  break;
                }
              for(int j = i+1; j<=R; j++) {
                  int N = i* j;
                    if( N % 2019 < result && N % 2019 > 0 ) {
                        result = N % 2019;
                    } else if(N%2019 == 0){
                      result = N % 2019;
                      break;
                    }
                }
            } if(i%2019 == 0 || result == 0){
                  result = 0;
                  break;
                } i%2019 == 0 || result == 0 i%2019 == 0 i%2019 i 2019 0 result == 0 result 0 {
                  result = 0;
                  break;
                } result = 0 result 0 break; for(int j = i+1; j<=R; j++) {
                  int N = i* j;
                    if( N % 2019 < result && N % 2019 > 0 ) {
                        result = N % 2019;
                    } else if(N%2019 == 0){
                      result = N % 2019;
                      break;
                    }
                } int j = i+1; int j = i+1; j i+1 i 1 j<=R j R j++ j++ j {
                  int N = i* j;
                    if( N % 2019 < result && N % 2019 > 0 ) {
                        result = N % 2019;
                    } else if(N%2019 == 0){
                      result = N % 2019;
                      break;
                    }
                } {
                  int N = i* j;
                    if( N % 2019 < result && N % 2019 > 0 ) {
                        result = N % 2019;
                    } else if(N%2019 == 0){
                      result = N % 2019;
                      break;
                    }
                } int N = i* j; N i* j i j if( N % 2019 < result && N % 2019 > 0 ) {
                        result = N % 2019;
                    } else if(N%2019 == 0){
                      result = N % 2019;
                      break;
                    } N % 2019 < result && N % 2019 > 0 N % 2019 < result N % 2019 N 2019 result N % 2019 > 0 N % 2019 N 2019 0 {
                        result = N % 2019;
                    } result = N % 2019 result N % 2019 N 2019 if(N%2019 == 0){
                      result = N % 2019;
                      break;
                    } N%2019 == 0 N%2019 N 2019 0 {
                      result = N % 2019;
                      break;
                    } result = N % 2019 result N % 2019 N 2019 break; System.out.println(result) System.out.println System.out System System.out result String[] args args public class Main {

    public static void main(String[] args) {
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        try {
            String str = br.readLine();
            String input[] = str.split(" ");
            int L = Integer.valueOf(input[0]);
            int R = Integer.valueOf(input[1]);
            
            int result = 2018;

          if(R-L >2019){
            R = L+2019;
          }
          if(L > 2019 && L/2019 == R/2019){
            L %= 2019;
            R %= 2019;
          }

            for(int i = L; i<R; i++) {
				if(i%2019 == 0 || result == 0){
                  result = 0;
                  break;
                }
              for(int j = i+1; j<=R; j++) {
                  int N = i* j;
                    if( N % 2019 < result && N % 2019 > 0 ) {
                        result = N % 2019;
                    } else if(N%2019 == 0){
                      result = N % 2019;
                      break;
                    }
                }
            }
            System.out.println(result);
            
            
        }catch(IOException e) {
            
        }
    }

} public class Main {

    public static void main(String[] args) {
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        try {
            String str = br.readLine();
            String input[] = str.split(" ");
            int L = Integer.valueOf(input[0]);
            int R = Integer.valueOf(input[1]);
            
            int result = 2018;

          if(R-L >2019){
            R = L+2019;
          }
          if(L > 2019 && L/2019 == R/2019){
            L %= 2019;
            R %= 2019;
          }

            for(int i = L; i<R; i++) {
				if(i%2019 == 0 || result == 0){
                  result = 0;
                  break;
                }
              for(int j = i+1; j<=R; j++) {
                  int N = i* j;
                    if( N % 2019 < result && N % 2019 > 0 ) {
                        result = N % 2019;
                    } else if(N%2019 == 0){
                      result = N % 2019;
                      break;
                    }
                }
            }
            System.out.println(result);
            
            
        }catch(IOException e) {
            
        }
    }

} Main
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;

public class Main {

    public static void main(String[] args) {
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        try {
            String str = br.readLine();
            String input[] = str.split(" ");
            int L = Integer.valueOf(input[0]);
            int R = Integer.valueOf(input[1]);
            
            int result = 2018;

          if(R-L >2019){
            R = L+2019;
          }
          if(L > 2019 && L/2019 == R/2019){
            L %= 2019;
            R %= 2019;
          }

            for(int i = L; i<R; i++) {
				if(i%2019 == 0 || result == 0){
                  result = 0;
                  break;
                }
              for(int j = i+1; j<=R; j++) {
                  int N = i* j;
                    if( N % 2019 < result && N % 2019 > 0 ) {
                        result = N % 2019;
                    } else if(N%2019 == 0){
                      result = N % 2019;
                      break;
                    }
                }
            }
            System.out.println(result);
            
            
        }catch(IOException e) {
            
        }
    }

}