#include<bits/stdc++.h>

using namespace std;
using   ll=long long;

#define fast        	ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0)

#define endl        	"\n"
#define pb          	push_back
#define mp          	make_pair
#define F           	first
#define S           	second
#define int             long long int
#define pll				pair<int , int>

#define ALL(v)      	v.begin(),v.end()
#define ALLR(v)     	v.rbegin(),v.rend()
#define pii         	3.14159265358979323
#define inf     		LLONG_MAX
#define ones(x)     	__builtin_popcount(x)
#define fill(a,b)   	memset(a,b,sizeof(a))
#define mod 			1000000007
#define hell            998244353 

ll mod_pow(ll a,ll b,ll m) 
{
    ll res = 1;
    while(b)	
    {
        if(b&1) 	
        {
        	res=(res*a) % m;
        }
        a=(a*a) % m;
        b>>=1;
    }
    return res;
}

ll mod_inverse(ll a) 
{
	return mod_pow(a , mod-2 , mod);
}

void solve() 
{
	int  l , r;
	
	cin >> l >> r;
	
	int lol = 2019;
	
	int ans = inf;
	
	for(int i = 1; i <= 2019; ++i) {
		int num = (l/2019)*2019;
		
		num += i;
		
		if(num < l) {
			num += 2019;
		}
		
		//cout << num << endl;
		
		if(num > r) {
			continue;
		}
		
		for(int j = 1; j <= 2019; ++j) {
			int tm;
			if(i == j) {
				tm = num + 2019;
			}
			else {
			tm = (l/2019)*2019;
			
			tm += j;
			
			if(tm < l) {
				tm += 2019;
			}
		
			}
			
			if(num >= l && num <= r && tm >= l && tm <= r) {
				ans = min(ans , (num*tm)%2019);
			}
		}
	}
	
	cout << ans;
}

signed main() {
    fast;
    
    int t = 1;
    
	//cin >> t;
    
    while(t--) {
        solve();
    }
 
    return 0;
}

#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define rep(n) for (ll i = 0; i < n; ++i)
#define rep2(i, n) for (ll i = 0; i < n; ++i)
#define rep3(i, a, b) for (ll i = a; i < b; ++i)
#define rep4(i, a, b, c) for (ll i = a; i < b; i += c)
#define erep(n) for (ll i = 0; i <= n; ++i)
#define erep2(i, n) for (ll i = 0; i <= n; ++i)
#define erep3(i, a, b) for (ll i = a; i <= b; ++i)
#define erep4(i, a, b, c) for (ll i = a; i <= b; i += c)
#define rrep(i, a, b) for (ll i = a; i > b; --i)
#define rrep2(i, a, b, c) for (ll i = a; i > b; i -= c)
#define errep(i, a, b) for (ll i = a; i >= b; --i)
#define errep2(i, a, b, c) for (ll i = a; i >= b; i -= c)
#define print(a) cout << a << endl;
#define printVec(v) printf("{"); for (const auto& i : v) { std::cout << i << ", "; } printf("}\n");
#define cin(x) cin >> x;
const ll MOD = 1000000007;
const double PI = 3.14159265358979323846264338327950;
inline int newline() { putchar('\n'); return 0; }

int main() {
    ll left, right;
    cin(left); cin(right);

    if (2019 - left % 2019 <= right - left) {
        print(0);
        return 0;

    } else {
        ll result = LLONG_MAX;
        rep3(i, left, right) {
            erep3(j, i + 1, right) {
                if (i * j % 2019 < result) result = i * j % 2019;
            }
        }
        print(result);
        return 0;
    }
}