import java.util.*;
 
public class Main {
  public static void main (String[] arg) {
    Scanner scan = new Scanner(System.in);
    long L = scan.nextLong();
    long R = scan.nextLong();
    long min = 2019;
    
    if(R-L >= 2018-(L%2019)){
      System.out.println(0);
      return;
    } else {
      for(Long i = L; i < R; i++){
        for(int j = 1; j <= R-i; j++){
          if((i*(i+j))%2019 < min){
            min = (i*(i+j))%2019;
          }
        }
      }
      System.out.println(min);
    }
  }
} import java.util.*; util.* java public class Main {
  public static void main (String[] arg) {
    Scanner scan = new Scanner(System.in);
    long L = scan.nextLong();
    long R = scan.nextLong();
    long min = 2019;
    
    if(R-L >= 2018-(L%2019)){
      System.out.println(0);
      return;
    } else {
      for(Long i = L; i < R; i++){
        for(int j = 1; j <= R-i; j++){
          if((i*(i+j))%2019 < min){
            min = (i*(i+j))%2019;
          }
        }
      }
      System.out.println(min);
    }
  }
} Main public static void main (String[] arg) {
    Scanner scan = new Scanner(System.in);
    long L = scan.nextLong();
    long R = scan.nextLong();
    long min = 2019;
    
    if(R-L >= 2018-(L%2019)){
      System.out.println(0);
      return;
    } else {
      for(Long i = L; i < R; i++){
        for(int j = 1; j <= R-i; j++){
          if((i*(i+j))%2019 < min){
            min = (i*(i+j))%2019;
          }
        }
      }
      System.out.println(min);
    }
  } main {
    Scanner scan = new Scanner(System.in);
    long L = scan.nextLong();
    long R = scan.nextLong();
    long min = 2019;
    
    if(R-L >= 2018-(L%2019)){
      System.out.println(0);
      return;
    } else {
      for(Long i = L; i < R; i++){
        for(int j = 1; j <= R-i; j++){
          if((i*(i+j))%2019 < min){
            min = (i*(i+j))%2019;
          }
        }
      }
      System.out.println(min);
    }
  } Scanner scan = new Scanner(System.in); scan new Scanner(System.in) long L = scan.nextLong(); L scan.nextLong() scan.nextLong scan long R = scan.nextLong(); R scan.nextLong() scan.nextLong scan long min = 2019; min 2019 if(R-L >= 2018-(L%2019)){
      System.out.println(0);
      return;
    } else {
      for(Long i = L; i < R; i++){
        for(int j = 1; j <= R-i; j++){
          if((i*(i+j))%2019 < min){
            min = (i*(i+j))%2019;
          }
        }
      }
      System.out.println(min);
    } R-L >= 2018-(L%2019) R-L R L 2018-(L%2019) 2018 (L%2019) L 2019 {
      System.out.println(0);
      return;
    } System.out.println(0) System.out.println System.out System System.out 0 return; {
      for(Long i = L; i < R; i++){
        for(int j = 1; j <= R-i; j++){
          if((i*(i+j))%2019 < min){
            min = (i*(i+j))%2019;
          }
        }
      }
      System.out.println(min);
    } for(Long i = L; i < R; i++){
        for(int j = 1; j <= R-i; j++){
          if((i*(i+j))%2019 < min){
            min = (i*(i+j))%2019;
          }
        }
      } Long i = L; Long i = L; i L i < R i R i++ i++ i {
        for(int j = 1; j <= R-i; j++){
          if((i*(i+j))%2019 < min){
            min = (i*(i+j))%2019;
          }
        }
      } {
        for(int j = 1; j <= R-i; j++){
          if((i*(i+j))%2019 < min){
            min = (i*(i+j))%2019;
          }
        }
      } for(int j = 1; j <= R-i; j++){
          if((i*(i+j))%2019 < min){
            min = (i*(i+j))%2019;
          }
        } int j = 1; int j = 1; j 1 j <= R-i j R-i R i j++ j++ j {
          if((i*(i+j))%2019 < min){
            min = (i*(i+j))%2019;
          }
        } {
          if((i*(i+j))%2019 < min){
            min = (i*(i+j))%2019;
          }
        } if((i*(i+j))%2019 < min){
            min = (i*(i+j))%2019;
          } (i*(i+j))%2019 < min (i*(i+j))%2019 (i*(i+j)) i (i+j) i j 2019 min {
            min = (i*(i+j))%2019;
          } min = (i*(i+j))%2019 min (i*(i+j))%2019 (i*(i+j)) i (i+j) i j 2019 System.out.println(min) System.out.println System.out System System.out min String[] arg arg public class Main {
  public static void main (String[] arg) {
    Scanner scan = new Scanner(System.in);
    long L = scan.nextLong();
    long R = scan.nextLong();
    long min = 2019;
    
    if(R-L >= 2018-(L%2019)){
      System.out.println(0);
      return;
    } else {
      for(Long i = L; i < R; i++){
        for(int j = 1; j <= R-i; j++){
          if((i*(i+j))%2019 < min){
            min = (i*(i+j))%2019;
          }
        }
      }
      System.out.println(min);
    }
  }
} public class Main {
  public static void main (String[] arg) {
    Scanner scan = new Scanner(System.in);
    long L = scan.nextLong();
    long R = scan.nextLong();
    long min = 2019;
    
    if(R-L >= 2018-(L%2019)){
      System.out.println(0);
      return;
    } else {
      for(Long i = L; i < R; i++){
        for(int j = 1; j <= R-i; j++){
          if((i*(i+j))%2019 < min){
            min = (i*(i+j))%2019;
          }
        }
      }
      System.out.println(min);
    }
  }
} Main
import java.util.*;
 
public class Main {
  public static void main (String[] arg) {
    Scanner scan = new Scanner(System.in);
    long L = scan.nextLong();
    long R = scan.nextLong();
    long min = 2019;
    
    if(R-L >= 2018-(L%2019)){
      System.out.println(0);
      return;
    } else {
      for(Long i = L; i < R; i++){
        for(int j = 1; j <= R-i; j++){
          if((i*(i+j))%2019 < min){
            min = (i*(i+j))%2019;
          }
        }
      }
      System.out.println(min);
    }
  }
}