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

int main(){
	LL n, m, up, ans = 3000;
	cin >> n >> m;
	up = min(m, n + 2019);
	for(LL i = n; i < up; i++)
		for(LL j = i + 1; j <= up; j++)
			ans = min(ans, (i % 2019 * j % 2019) % 2019);
	cout << ans << endl;
}