import std.stdio, std.string, std.conv, std.algorithm;

immutable int n = 2019;

void divmod(int x, ref int a, ref int b) {
    a = x / n;
    b = x % n;
}

void main() {
    int[] tmp = readln.split.to!(int[]);
    int ld, lm, rd, rm;
    divmod(tmp[0], ld, lm);
    divmod(tmp[1], rd, rm);
    if (ld != rd) {
        0.writeln;
    } else {
        int minv = n;
        foreach (i; lm .. rm) {
            foreach (j; i+1 .. rm+1) {
                minv = min(minv, i * j % n);
            }
        }
        minv.writeln;
    }
}