fun main(arr:Array<String>) {
    val ans = readLine()!!.split(" ").map { it.toLong() }.let { getAns(it[0], it[1]) }
    println(ans)
}

fun getAns(l:Long, r:Long):Int {
    var num = l / 2019
    if(l % 2019 != 0L) {
        num++
    }
    num *= 2019
    if(num <= r) {
        return 0
    }
    num = l / 673
    if(l % 673 != 0L) {
        num++
    }
    num *= 673
    if(num <= r) {
        for(i in (l..r)) {
            if(i % 3  == 0L) {
                return 0
            }
        }
    }
    var ans = 2019
    for(i in (l..r)) {
        for(j in (l..r)) {
            if(i == j) {
                continue
            }
            ans = Math.min(ans, ((i*j)%2019).toInt())
        }
    }
    return ans
}
