fun main(args: Array<String>) {
    val n = readLine()!!.toInt()
    val p = readLine()!!.replace(" ", "").toInt()
    val q = readLine()!!.replace(" ", "").toInt()

    var fact = 1
    repeat(n) {
        fact *= (it+1)
    }
    var pPos = 0
    var qPos = 0

    fun chk(i:Int) : Boolean{
        val s = i.toString().toCharArray()
        if (s.size != n) return false
        val f = BooleanArray(n + 1){ false }
        s.forEach {
            val c = it.toString().toInt()
            when {
                c == 0 -> return false
                c > n -> return false
                f[c] -> return false
                else -> f[c] = true
            }
        }
        return true
    }
    var cnt = 0
    var i = Math.min(p,q)
    while(i <= Math.max(p,q)) {
        if (chk(i)) cnt++
        if (i == p) pPos = cnt
        if (i == q) qPos = cnt
        i+=9
    }
    println(Math.abs(pPos - qPos))
}
