fun main(args: Array<String>) {
    val (L, R) = readLine()!!.split(" ").map(String::toInt)
    if (L / 2019 != R / 2019) {
        println(0)
        return
    }
    val D = (L..R).map { it % 2019 }.toTypedArray()
    var min = Int.MAX_VALUE
    for (i in 0 until D.size - 1) {
        for (j in i + 1 until D.size) {
            min = min.coerceAtMost((D[i] * D[j]) % 2019)
        }
    }
    println(min)
}