import java.util.*;

public class Main{
    public static void main(String[] args) {
      Scanner sc = new Scanner(System.in);

      int L=sc.nextInt();
      int R=sc.nextInt();

      //0 < L <= i < j <= R

      int mod,ii,jj;
      int ans = 2019;
      int cnt =0;

      for(int i=L;i<R;i++){
        ii = i % 2019;
        for(int j=i+1;j<=R;j++){
          jj = j % 2019;
          mod = (ii*jj) % 2019;
          if(mod<ans) ans=mod;
          if(ans==0){break;}
        }
        if(ans==0){break;}
      }
      System.out.println(ans);

//kan nin gu

    }
} import java.util.*; util.* java public class Main{
    public static void main(String[] args) {
      Scanner sc = new Scanner(System.in);

      int L=sc.nextInt();
      int R=sc.nextInt();

      //0 < L <= i < j <= R

      int mod,ii,jj;
      int ans = 2019;
      int cnt =0;

      for(int i=L;i<R;i++){
        ii = i % 2019;
        for(int j=i+1;j<=R;j++){
          jj = j % 2019;
          mod = (ii*jj) % 2019;
          if(mod<ans) ans=mod;
          if(ans==0){break;}
        }
        if(ans==0){break;}
      }
      System.out.println(ans);

//kan nin gu

    }
} Main public static void main(String[] args) {
      Scanner sc = new Scanner(System.in);

      int L=sc.nextInt();
      int R=sc.nextInt();

      //0 < L <= i < j <= R

      int mod,ii,jj;
      int ans = 2019;
      int cnt =0;

      for(int i=L;i<R;i++){
        ii = i % 2019;
        for(int j=i+1;j<=R;j++){
          jj = j % 2019;
          mod = (ii*jj) % 2019;
          if(mod<ans) ans=mod;
          if(ans==0){break;}
        }
        if(ans==0){break;}
      }
      System.out.println(ans);

//kan nin gu

    } main {
      Scanner sc = new Scanner(System.in);

      int L=sc.nextInt();
      int R=sc.nextInt();

      //0 < L <= i < j <= R

      int mod,ii,jj;
      int ans = 2019;
      int cnt =0;

      for(int i=L;i<R;i++){
        ii = i % 2019;
        for(int j=i+1;j<=R;j++){
          jj = j % 2019;
          mod = (ii*jj) % 2019;
          if(mod<ans) ans=mod;
          if(ans==0){break;}
        }
        if(ans==0){break;}
      }
      System.out.println(ans);

//kan nin gu

    } Scanner sc = new Scanner(System.in); sc new Scanner(System.in) int L=sc.nextInt(); L sc.nextInt() sc.nextInt sc int R=sc.nextInt(); R sc.nextInt() sc.nextInt sc int mod mod ii ii jj; jj int ans = 2019; ans 2019 int cnt =0; cnt 0 for(int i=L;i<R;i++){
        ii = i % 2019;
        for(int j=i+1;j<=R;j++){
          jj = j % 2019;
          mod = (ii*jj) % 2019;
          if(mod<ans) ans=mod;
          if(ans==0){break;}
        }
        if(ans==0){break;}
      } int i=L; int i=L; i L i<R i R i++ i++ i {
        ii = i % 2019;
        for(int j=i+1;j<=R;j++){
          jj = j % 2019;
          mod = (ii*jj) % 2019;
          if(mod<ans) ans=mod;
          if(ans==0){break;}
        }
        if(ans==0){break;}
      } {
        ii = i % 2019;
        for(int j=i+1;j<=R;j++){
          jj = j % 2019;
          mod = (ii*jj) % 2019;
          if(mod<ans) ans=mod;
          if(ans==0){break;}
        }
        if(ans==0){break;}
      } ii = i % 2019 ii i % 2019 i 2019 for(int j=i+1;j<=R;j++){
          jj = j % 2019;
          mod = (ii*jj) % 2019;
          if(mod<ans) ans=mod;
          if(ans==0){break;}
        } int j=i+1; int j=i+1; j i+1 i 1 j<=R j R j++ j++ j {
          jj = j % 2019;
          mod = (ii*jj) % 2019;
          if(mod<ans) ans=mod;
          if(ans==0){break;}
        } {
          jj = j % 2019;
          mod = (ii*jj) % 2019;
          if(mod<ans) ans=mod;
          if(ans==0){break;}
        } jj = j % 2019 jj j % 2019 j 2019 mod = (ii*jj) % 2019 mod (ii*jj) % 2019 (ii*jj) ii jj 2019 if(mod<ans) ans=mod; mod<ans mod ans ans=mod ans mod if(ans==0){break;} ans==0 ans 0 {break;} break; if(ans==0){break;} ans==0 ans 0 {break;} break; 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) {
      Scanner sc = new Scanner(System.in);

      int L=sc.nextInt();
      int R=sc.nextInt();

      //0 < L <= i < j <= R

      int mod,ii,jj;
      int ans = 2019;
      int cnt =0;

      for(int i=L;i<R;i++){
        ii = i % 2019;
        for(int j=i+1;j<=R;j++){
          jj = j % 2019;
          mod = (ii*jj) % 2019;
          if(mod<ans) ans=mod;
          if(ans==0){break;}
        }
        if(ans==0){break;}
      }
      System.out.println(ans);

//kan nin gu

    }
} public class Main{
    public static void main(String[] args) {
      Scanner sc = new Scanner(System.in);

      int L=sc.nextInt();
      int R=sc.nextInt();

      //0 < L <= i < j <= R

      int mod,ii,jj;
      int ans = 2019;
      int cnt =0;

      for(int i=L;i<R;i++){
        ii = i % 2019;
        for(int j=i+1;j<=R;j++){
          jj = j % 2019;
          mod = (ii*jj) % 2019;
          if(mod<ans) ans=mod;
          if(ans==0){break;}
        }
        if(ans==0){break;}
      }
      System.out.println(ans);

//kan nin gu

    }
} Main
import java.util.*;

public class Main{
    public static void main(String[] args) {
      Scanner sc = new Scanner(System.in);

      int L=sc.nextInt();
      int R=sc.nextInt();

      //0 < L <= i < j <= R

      int mod,ii,jj;
      int ans = 2019;
      int cnt =0;

      for(int i=L;i<R;i++){
        ii = i % 2019;
        for(int j=i+1;j<=R;j++){
          jj = j % 2019;
          mod = (ii*jj) % 2019;
          if(mod<ans) ans=mod;
          if(ans==0){break;}
        }
        if(ans==0){break;}
      }
      System.out.println(ans);

//kan nin gu

    }
}
