import java.util.*;

public class Main{
  public static void main(String[] args){
    Scanner sc = new Scanner(System.in);
    long L = sc.nextLong();
    long R = sc.nextLong();
    long mL = L%2019;
    long mR = R%2019;
    long out = 3000;
    if(R-L >= 2018 || mL > mR){
      System.out.println(0);
    } else {
      for (long i=mL; i<=mR-1; i++) {
        for (long j=i+1; j<=mR; j++) {
          if(out > (i*j)%2019){
            out = (i*j)%2019;
          }
        }
      }
      System.out.println(out);
    }
  }
}
 import java.util.*; util.* java public class Main{
  public static void main(String[] args){
    Scanner sc = new Scanner(System.in);
    long L = sc.nextLong();
    long R = sc.nextLong();
    long mL = L%2019;
    long mR = R%2019;
    long out = 3000;
    if(R-L >= 2018 || mL > mR){
      System.out.println(0);
    } else {
      for (long i=mL; i<=mR-1; i++) {
        for (long j=i+1; j<=mR; j++) {
          if(out > (i*j)%2019){
            out = (i*j)%2019;
          }
        }
      }
      System.out.println(out);
    }
  }
} Main public static void main(String[] args){
    Scanner sc = new Scanner(System.in);
    long L = sc.nextLong();
    long R = sc.nextLong();
    long mL = L%2019;
    long mR = R%2019;
    long out = 3000;
    if(R-L >= 2018 || mL > mR){
      System.out.println(0);
    } else {
      for (long i=mL; i<=mR-1; i++) {
        for (long j=i+1; j<=mR; j++) {
          if(out > (i*j)%2019){
            out = (i*j)%2019;
          }
        }
      }
      System.out.println(out);
    }
  } main {
    Scanner sc = new Scanner(System.in);
    long L = sc.nextLong();
    long R = sc.nextLong();
    long mL = L%2019;
    long mR = R%2019;
    long out = 3000;
    if(R-L >= 2018 || mL > mR){
      System.out.println(0);
    } else {
      for (long i=mL; i<=mR-1; i++) {
        for (long j=i+1; j<=mR; j++) {
          if(out > (i*j)%2019){
            out = (i*j)%2019;
          }
        }
      }
      System.out.println(out);
    }
  } 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 mL = L%2019; mL L%2019 L 2019 long mR = R%2019; mR R%2019 R 2019 long out = 3000; out 3000 if(R-L >= 2018 || mL > mR){
      System.out.println(0);
    } else {
      for (long i=mL; i<=mR-1; i++) {
        for (long j=i+1; j<=mR; j++) {
          if(out > (i*j)%2019){
            out = (i*j)%2019;
          }
        }
      }
      System.out.println(out);
    } R-L >= 2018 || mL > mR R-L >= 2018 R-L R L 2018 mL > mR mL mR {
      System.out.println(0);
    } System.out.println(0) System.out.println System.out System System.out 0 {
      for (long i=mL; i<=mR-1; i++) {
        for (long j=i+1; j<=mR; j++) {
          if(out > (i*j)%2019){
            out = (i*j)%2019;
          }
        }
      }
      System.out.println(out);
    } for (long i=mL; i<=mR-1; i++) {
        for (long j=i+1; j<=mR; j++) {
          if(out > (i*j)%2019){
            out = (i*j)%2019;
          }
        }
      } long i=mL; long i=mL; i mL i<=mR-1 i mR-1 mR 1 i++ i++ i {
        for (long j=i+1; j<=mR; j++) {
          if(out > (i*j)%2019){
            out = (i*j)%2019;
          }
        }
      } {
        for (long j=i+1; j<=mR; j++) {
          if(out > (i*j)%2019){
            out = (i*j)%2019;
          }
        }
      } for (long j=i+1; j<=mR; j++) {
          if(out > (i*j)%2019){
            out = (i*j)%2019;
          }
        } long j=i+1; long j=i+1; j i+1 i 1 j<=mR j mR j++ j++ j {
          if(out > (i*j)%2019){
            out = (i*j)%2019;
          }
        } {
          if(out > (i*j)%2019){
            out = (i*j)%2019;
          }
        } if(out > (i*j)%2019){
            out = (i*j)%2019;
          } out > (i*j)%2019 out (i*j)%2019 (i*j) i j 2019 {
            out = (i*j)%2019;
          } out = (i*j)%2019 out (i*j)%2019 (i*j) i j 2019 System.out.println(out) System.out.println System.out System System.out out String[] args args public class Main{
  public static void main(String[] args){
    Scanner sc = new Scanner(System.in);
    long L = sc.nextLong();
    long R = sc.nextLong();
    long mL = L%2019;
    long mR = R%2019;
    long out = 3000;
    if(R-L >= 2018 || mL > mR){
      System.out.println(0);
    } else {
      for (long i=mL; i<=mR-1; i++) {
        for (long j=i+1; j<=mR; j++) {
          if(out > (i*j)%2019){
            out = (i*j)%2019;
          }
        }
      }
      System.out.println(out);
    }
  }
} public class Main{
  public static void main(String[] args){
    Scanner sc = new Scanner(System.in);
    long L = sc.nextLong();
    long R = sc.nextLong();
    long mL = L%2019;
    long mR = R%2019;
    long out = 3000;
    if(R-L >= 2018 || mL > mR){
      System.out.println(0);
    } else {
      for (long i=mL; i<=mR-1; i++) {
        for (long j=i+1; j<=mR; j++) {
          if(out > (i*j)%2019){
            out = (i*j)%2019;
          }
        }
      }
      System.out.println(out);
    }
  }
} Main
import java.util.*;

public class Main{
  public static void main(String[] args){
    Scanner sc = new Scanner(System.in);
    long L = sc.nextLong();
    long R = sc.nextLong();
    long mL = L%2019;
    long mR = R%2019;
    long out = 3000;
    if(R-L >= 2018 || mL > mR){
      System.out.println(0);
    } else {
      for (long i=mL; i<=mR-1; i++) {
        for (long j=i+1; j<=mR; j++) {
          if(out > (i*j)%2019){
            out = (i*j)%2019;
          }
        }
      }
      System.out.println(out);
    }
  }
}

