//DFSテンプレート
fun main(args: Array<String>) {
    var (N, U, V) = listOfInt()
    U -= 1; V -= 1
    val G = Array<MutableList<Int>>(N) { mutableListOf<Int>() }
    repeat(N - 1) {
        val (a, b) = listOfInt(-1)
        G[a].add(b)
        G[b].add(a)
    }
    val visit = Array<Int>(N) { 0 }
    fun visitClear() {
        repeat(N) {
            visit[it] = 0
        }
    }
    tailrec fun dfs(v: Int, d: Int) {
        visit[v] = d + 1
        for (next_v in G[v]) {
            if (visit[next_v] > 0) continue
            dfs(next_v, d + 1)
        }
    }
    var ans = 0
    while (U != V) {
        val du = Array<Int>(N) { 0 }
        G[U].forEach {
            visitClear(); dfs(U, 0)
            du[it] = visit[V]
            var dux = 0
            du.forEachIndexed { index, i -> if (dux < i) U = index }
        }
        ans += 1
        if (U != V) {
            val dv = Array<Int>(N) { 0 }
            G[V].forEach {
                visitClear(); dfs(U, 0)
                dv[it] = visit[U]
                var dvx = 1000001
                dv.forEachIndexed { index, i -> if (dvx > i) V = index }
            }
        }
    }
    println(ans)
}
fun next() = readLine()!!
fun nextInt() = Integer.parseInt(next())
fun listOfString() = next().split(" ")
fun listOfInt(delta: Int = 0) = listOfString().map { Integer.parseInt(it) + delta }
fun printErr(value: Any) = System.err.println(value)
