#include <iostream>
#include <algorithm>
#define flush fflush(stdout)
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
typedef pair<ll, ll> Pl;
const int mod = (int)1e9 + 7, INF = (int)1e9;
const int di[4] = { 1,0,-1,0 }, dj[4] = { 0,1,0,-1 };


int main(void) {
    int l, r, i, j, ans;

    scanf("%d%d", &l, &r);

    if (r - l >= 2019 || l % 2019 > r % 2019)
    {
        printf("0\n");
        return (0);
    }
    ans = 2019;
    i = l % 2019;
    while (i < r % 2019)
    {
        j = i + 1;
        while (j <= r % 2019)
        {
            if (ans > i * j % 2019)
                ans = i * j % 2019;
            j++;
        }
        i++;
    }

    printf("%d\n", ans);

    return 0;
}
/******************************************************************************

                              Online C++ Compiler.
               Code, Compile, Run and Debug C++ program online.
Write your code in this editor and press "Run" button to compile and execute it.

*******************************************************************************/

#include <bits/stdc++.h>
using namespace std;

long long remindersReps[2019];

int main()
{
    int L, R;
    cin >> L >> R;
    
    for(int i = 0; i < 2019; ++i)
    {
        remindersReps[i] = -1;
    }
    
    int el_lim = L +2020;
    if(R < el_lim)
        el_lim = R;
    for(int i = L; i <= el_lim ; ++i )
    {
        remindersReps[i%2019] = i;
    }
    
    long long reminders[2019];
    
    for(int i = 0; i< 2019;++i)
    {
        if(remindersReps[i]!=1)
            reminders[i] = remindersReps[i]%2019;
    }
    
    long long min = 3000;
    
    long long respL, respR;
    
    for(int i = 0; i < 2019; ++i)
    {
        for(int j = 0; j < 2019; ++j)
        {
            if(remindersReps[i] >= remindersReps[j] ||  remindersReps[i] == -1 || remindersReps[j] == -1)
                continue;
            
            long long temp = (reminders[i]*reminders[j])%2019;
            if( temp < min )
            {
                min = temp;
                respL = remindersReps[i];
                respR = remindersReps[j];
            }
        }
    }
    
    cout << min; 
}


