import std.stdio, std.algorithm, std.conv, std.array, std.string, std.math, std.typecons, std.numeric;

void main()
{
    auto lr = readln.split.to!(long[]).map!"a % 2019".array;
    if (lr[0] == lr[1]) {
        writeln(0);
        return;
    }
    auto L = lr[0];
    auto R = lr[1] + 1;
    if (R <= L) R += 2019;

    long x = long.max;
    foreach (l; L..R) {
        foreach (r; l+1..R) {
            x = min(x, l*r%2019);
        }
    }
    writeln(x);
}