fun main(args: Array<String>) {
    val (l, r) = readLine()!!.split(" ").map { it.toInt() }

    val mem = Array(2019) { IntArray(2019) { 0 } }

    for (i in 0 until 2019) {
        for (j in 0 until 2019) {
            mem[i][j] = i * j % 2019
        }
    }

    val cnt = IntArray(2019) { 0 }
    var loop = 0
    for (i in l..r) {
        cnt[i%2019] += 1
        loop += 1
        if (loop >= 4038) {
            break
        }
    }

    var ans = 2020
    for (i in 0 until 2019) {
        for (j in 0 until 2019) {

            if (i == j) {
                if(cnt[i]==2) {
                    ans = Math.min(ans, mem[i][j])
                }

                continue
            }

            if (cnt[i] > 0 && cnt[j] > 0){
                ans = Math.min(ans, mem[i][j])
            }
        }
    }

    println(ans)
}