from collections import deque
from math import ceil

def read():
    N, u, v = list(map(int, input().strip().split()))
    G = [list() for i in range(N+1)]
    for i in range(N-1):
        a, b = list(map(int, input().strip().split()))
        G[a].append(b)
        G[b].append(a)
    return N, u, v, G

def bfs(G, N, start, INF):
    D = [INF for i in range(N+1)]
    D[start] = 0
    q = deque()
    q.appendleft(start)
    while(len(q) > 0):
        s = q.pop()
        for i in range(len(G[s])):
            t = G[s][i]
            if D[t] == INF:
                D[t] = D[s] + 1
                q.appendleft(t)
    return D


def argmax(x):
    imax = 0
    for i, e in enumerate(x):
        if x[imax] < e:
            imax = i
    return imax

def solve(N, u, v, G, INF=-1000000):
    du = bfs(G, N, u, INF)
    dv = bfs(G, N, v, INF)
    du_opt = [x for x in du]
    for i in range(N+1):
        if du[i] >= dv[i]:
            du_opt[i] = INF
    idx = argmax(du_opt)
    return (du[idx] + dv[idx]) // 2


if __name__ == '__main__':
    inputs = read()
    print("%d" % solve(*inputs))
