import java.util.*
fun main(args: Array<String>){
	val cin = Scanner(System.`in`)
    val l = cin.nextInt()
    val r = cin.nextInt()

    val l_a = l / 2019
    val l_b = l % 2019
    val r_a = r / 2019
    val r_b = r % 2019

    if (l_a != r_a) {
        println(0)
    } else {
        var ans = 2018
        for (i in l_b..r_b-1) {
            for (j in i+1..r_b) {
                if (ans > (i*j)%2019) {
                    ans = (i*j)%2019
                }
            }
        }
        println(ans)
    }
}