import java.util.Scanner;

public class Main {
  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    long L = sc.nextInt();
    long R = sc.nextInt();
    int result = 2019;
    int tmp = 0;
    loop: for (; L < R; L++) {
      if (L % 2019 == 0) {
        result = 0;
        break;
      }
      for (long i = L + 1; i <= R; i++) {
        if (i % 2019 == 0) {
          result = 0;
          break loop;
        }
        tmp = (int) ((L * i) % 2019);
        if (tmp < result)
          result = tmp;
      }
    }
    System.out.println(result);
  }
} import java.util.Scanner; Scanner java.util public class Main {
  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    long L = sc.nextInt();
    long R = sc.nextInt();
    int result = 2019;
    int tmp = 0;
    loop: for (; L < R; L++) {
      if (L % 2019 == 0) {
        result = 0;
        break;
      }
      for (long i = L + 1; i <= R; i++) {
        if (i % 2019 == 0) {
          result = 0;
          break loop;
        }
        tmp = (int) ((L * i) % 2019);
        if (tmp < result)
          result = tmp;
      }
    }
    System.out.println(result);
  }
} Main public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    long L = sc.nextInt();
    long R = sc.nextInt();
    int result = 2019;
    int tmp = 0;
    loop: for (; L < R; L++) {
      if (L % 2019 == 0) {
        result = 0;
        break;
      }
      for (long i = L + 1; i <= R; i++) {
        if (i % 2019 == 0) {
          result = 0;
          break loop;
        }
        tmp = (int) ((L * i) % 2019);
        if (tmp < result)
          result = tmp;
      }
    }
    System.out.println(result);
  } main {
    Scanner sc = new Scanner(System.in);
    long L = sc.nextInt();
    long R = sc.nextInt();
    int result = 2019;
    int tmp = 0;
    loop: for (; L < R; L++) {
      if (L % 2019 == 0) {
        result = 0;
        break;
      }
      for (long i = L + 1; i <= R; i++) {
        if (i % 2019 == 0) {
          result = 0;
          break loop;
        }
        tmp = (int) ((L * i) % 2019);
        if (tmp < result)
          result = tmp;
      }
    }
    System.out.println(result);
  } Scanner sc = new Scanner(System.in); sc new Scanner(System.in) long L = sc.nextInt(); L sc.nextInt() sc.nextInt sc long R = sc.nextInt(); R sc.nextInt() sc.nextInt sc int result = 2019; result 2019 int tmp = 0; tmp 0 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) {
    Scanner sc = new Scanner(System.in);
    long L = sc.nextInt();
    long R = sc.nextInt();
    int result = 2019;
    int tmp = 0;
    loop: for (; L < R; L++) {
      if (L % 2019 == 0) {
        result = 0;
        break;
      }
      for (long i = L + 1; i <= R; i++) {
        if (i % 2019 == 0) {
          result = 0;
          break loop;
        }
        tmp = (int) ((L * i) % 2019);
        if (tmp < result)
          result = tmp;
      }
    }
    System.out.println(result);
  }
} public class Main {
  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    long L = sc.nextInt();
    long R = sc.nextInt();
    int result = 2019;
    int tmp = 0;
    loop: for (; L < R; L++) {
      if (L % 2019 == 0) {
        result = 0;
        break;
      }
      for (long i = L + 1; i <= R; i++) {
        if (i % 2019 == 0) {
          result = 0;
          break loop;
        }
        tmp = (int) ((L * i) % 2019);
        if (tmp < result)
          result = tmp;
      }
    }
    System.out.println(result);
  }
} Main
import java.util.Scanner;

public class Main {
  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    long L = sc.nextInt();
    long R = sc.nextInt();
    int result = 2019;
    int tmp = 0;
    loop: for (; L < R; L++) {
      if (L % 2019 == 0) {
        result = 0;
        break;
      }
      for (long i = L + 1; i <= R; i++) {
        if (i % 2019 == 0) {
          result = 0;
          break loop;
        }
        tmp = (int) ((L * i) % 2019);
        if (tmp < result)
          result = tmp;
      }
    }
    System.out.println(result);
  }
}