fun main(args: Array<String>) {
    val m = (0..2018).map { i -> (0..2018).map { (i*it)%2019 } }
    val (l, r) = readLine()!!.split(" ").map { it.toInt() }

    if(r-l>=2018) {
        println(0)
        return
    }

    val f = BooleanArray(2019)
    (l..r).toList().combinationPairs().forEach {
        f[((it.first%2019)*(it.second%2019))%2019] = true
    }

    val ans = f.indexOf(true)
    println(ans)
}

fun <E> List<E>.combinationPairs(): List<Pair<E, E>>
        = this.indices.flatMap { i -> (i+1 until this.size).map { j -> Pair(this[i], this[j]) } }

