import java.io.*;

class Main{
    public static void main(String[] args) throws Exception{
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        String sb1 = br.readLine();
        String[] a = sb1.split(" ");
        long[] c = new long[a.length];
        long[] b = new long[a.length];
        long d  = 2019;
        for(int i = 0;i < a.length;i++){
            c[i] = Long.parseLong(a[i]);
            b[i] = c[i]/d;
        }
        
        if(b[0] == b[1]){
            for (long i = c[0]; i < c[1]; i++) {
                for (long j = i+1; j <= c[1]; j++) {
                    long e = i % 2019;
                    long f = j % 2019;
                    long g = e * f;
                    d = Math.min(d, g % 2019);
                }
            }
            System.out.println(d);
        }  else {
            System.out.println(0);
        }
        
    }
}
/tmp/hf-datasets-cache/medium/datasets/42704881117311-config-parquet-and-info-qiankunmu-Project_CodeNet-896c9d36/hub/datasets--qiankunmu--Project_CodeNet_Python800_and_Java250/snapshots/c899fde44a77ba1cc14973ed3de064e4ff3aadc7/Project_CodeNet_Java250.tar.gz