using System;
using System.Collections.Generic;
using System.Linq;

namespace cs
{
    public class Program
    {
        public static void Main(string[] args)
        {


            
            var input = Array.ConvertAll(Console.ReadLine().Split(' '), long.Parse);
            
            var L = input[0];
            var R = input[1];

            var min = new long[2];
            var ans = new long[2];
            min[0] = long.MaxValue;
            ans[0] = int.MaxValue;
            var primeFlag = new Boolean[2];
            var testMin = long.MaxValue;

            for(long i = L; i <= R; i++){

                if(i % 3 == 0){
                    primeFlag[0] = true;
                }
                if(i % 673 == 0){
                    primeFlag[1] = true;
                }
                if(i % 2019 == 0 || ( primeFlag[0] && primeFlag[1])){
                    Console.WriteLine("0");
                    //Console.ReadKey();
                    return;
                }
                for(long k = L; k < i; k++){
                    testMin = Math.Min((i * k) % 2019, testMin);
                }
                
                // if(i % 2019 < min[0]){

                //     min[1] = min[0];
                //     min[0] = i % 2019;
                //     ans[1] = ans[0];
                //     ans[0] = i;
                //     //Console.WriteLine("a");
                // }else if(i % 2019 < min[1]){
                //     min[1] = i % 2019;
                //     ans[1] = i;
                // }

            }

           // Console.WriteLine(min[0] + "a" + min[1]);
            Console.WriteLine(testMin);
        
            
            
/*
            Console.WriteLine();
            Console.WriteLine("続行するにはアレ");*/
            //Console.ReadKey();
           
        }

        private static long Factorial(long number)
{
	if (number < 0)
		return -1; //Error

	long result = 1;

	for (long i = 1; i <= number; ++i)
		result *= i;

	return result;
}
public static long ncr2(long n, long r){
    var fact = n;
    var fact2 = r;
    long fact1;
    long per;
            for (long i = n - 1; i >= 1; i--)
            {
                fact = fact * i;
            }
            fact2 = r;
            for (long i = r - 1; i >= 1; i--)
            {
                fact2 = fact2 * i;
            }
            long number;
            number = n - r;
            fact1 = number;
            for (long i = number - 1; i >= 1; i--)
            {
                fact1 = fact1 * i;
            }
            fact1 = fact2 * fact1;
            per = fact / fact1;
            return per;
}
public static long NCR(long n, long r)
{
	return Factorial(n) / (Factorial(r) * Factorial(n - r));
}

        class vec{
            long from{get;set;}
            long to{get;set;}

            public vec(long[] x){
                from = x[0];
                to = x[1];
            }

        }


        public static long modder(){
            return (long)Math.Pow(10,9) + 7;
        }

        public static long GCD(long n, long m){
            
            if(m % n == 0) return n;
            else return GCD(m%n, n);

        }

        public static long LCD(long n, long m){

            return m * n / GCD(n,m);
        }
    }
}


Measured memory_bytes: 13140