
fun main(args: Array<String>) {
    val (l, r) = readLine()!!.split(' ').map(String::toInt)
    val ml = l % 2019
    val mr = r % 2019
    print(when{
        r - l > 2019 -> 0
        ml >= mr -> 0
        ml == 0 || mr == 0 -> 0
        else -> {
            val ls = (ml..mr).toList()
            ls.indices.flatMap { i -> (i+1 until ls.size).map { j ->
                ls[i] * ls[j] % 2019
            }
            }.min()
        }
    })
}