#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
using namespace std;
using ll = long long;
using P = pair<int,int>;

int main() {
  ll l, r;
  cin >> l >> r;
  ll ans = 2018;
  if (r - l >= 2 * 2019) {
    rep(i, 2019) rep(j, 2019) ans = min(ans, (ll)i * j % 2019);
  } else if (r - l >= 2019) {
    vector<int> cnt(2019, 0);
    for (ll i = l; i <= r; ++i) ++cnt[l % 2019];
    rep(i, 2019) rep(j, 2019) {
      if (i == j && cnt[i] == 1) continue;
      ans = min(ans, (ll)i * j % 2019);
    }
  } else {
    for (ll i = l; i <= r; ++i) {
      for (ll j = i + 1; j <= r; ++j) {
        ans = min(ans, i * j % 2019);
      }
    }
  }
  cout << ans << endl;
  return 0;
}
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define rep(i,n) for(int i = 0; i < (n); i++)
#define all(v) v.begin(), v.end()
#define MOD 1000000007
const int INF = 1LL<<30;
 
int main(){
    ll l,r;
    cin>>l>>r;
    
    ll ans=3000;
    for(int i=l;i<=min(r,l+3000);i++){
        for(int j=i+1;j<=min(r,l+3000);j++){
            ll tmp=((i%2019)*(j%2019))%2019;
            ans=min(ans,tmp);
        }
    }

    cout<<ans<<endl;
}