#include <bits/stdc++.h>
using namespace std;
void solve(int test_case) {
  long long l, r;
  cin >> l >> r;
  if ((r / 2019) - (l / 2019) > 0) {
    cout << 0;
  } else {
    cout << (l * (l + 1)) % (long long)2019;
  }
}
int main() {
  ios::sync_with_stdio(0);
  cin.tie(0);
  int t = 1;
  for (int i = 1; i <= t; i++) {
    solve(i);
  }
  return 0;
}
