fun main(args : Array<String>) {
    val (L, R) = readLine()!!.split(" ").map { it.toLong() }
    val MOD = 2019
    var i = L
    val candidates = mutableListOf<Int>()
    candidates.add(i.mod(2019).toInt())
    (0..2019 * 4).forEach {
        i++
        if (i <= R) {
            candidates.add(i.mod(2019).toInt())
        }
    }

    val size = candidates.size

    if (size <= 1) {
        println(0)
        return
    }

    var answer = Int.MAX_VALUE
    (0..(size - 2)).forEach { i ->
        ((i+1)..(size - 1)).forEach { j ->
            answer = Math.min(answer, (candidates[i] * candidates[j]).mod(2019))
        }
    }

    println(answer)
}