#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll, ll> P;
const ll INF = 100000000;
#define rep1(i, n) for (ll i=0; i<(n); i++) 
#define rep2(i, k, n) for (ll i=k; i<(n); i++)
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }

const ll mod = 2019;

int main() {
    ll l, r;
    cin >> l >> r;
    map<ll, ll> m;
    for (ll i = l; i <= r && i <= l+5000; i++){
        m[i%mod]++;
    }
    ll ans = 2020;
    vector<ll> a;
    for (auto x: m){
        rep1(i, x.second) a.push_back(x.first);
    }
    ll n = a.size();
    for (ll i=0; i<(n); i++){
        for (ll j=i+1; j<(n); j++){
            ans = min(ans, a[i]*a[j]%2019);
        }
    }
    cout << ans << endl;
    //printf("%.12f", ans);
}
#include <algorithm>
#include <cmath>
#include <deque>
#include <iomanip>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <tuple>
#include <vector>
using namespace std;
typedef long long ll;
ll const INF = 1LL << 60;
ll search(ll l, ll r) {
  ll ret = INF;
  for (ll i = l; i <= r; i++) {
    for (ll j = i + 1; j <= r; j++) {
      ret = min((i * j) % 2019, ret);
    }
  }
  return ret;
}
int main() {
  ll l, r;
  cin >> l >> r;
  if (l <= 2019 && 2019 <= r) {
    cout << 0 << endl;
  } else if (l < 2019 && r < 2019) {
    cout << search(l, r) << endl;
  } else if (r - l < 2019) {
    cout << search(l, r) << endl;
  } else {
    cout << 0 << endl;
  }
  return 0;
}