from heapq import heapify, heappop, heappush

N, u, v = list(map(int, input().split()))
A = [[] for _ in range(N + 1)]
for _ in range(N - 1):
    _u, _v = list(map(int, input().split()))
    A[_u].append(_v)
    A[_v].append(_u)

# 距離の計算 (青木)
INF = int(1e18)
dist = {_v: INF for _v in range(1, N + 1)}
dist[v] = 0
queue = [(0, v)]
heapify(queue)
while len(queue) > 0:
    d, node = heappop(queue)
    for ngv in A[node]:
        if dist[ngv] > d + 1:  # INF:
            dist[ngv] = d + 1
            heappush(queue, (d + 1, ngv))

# 青木の距離が最短
# 高橋の距離は青木の距離+1かどうか
# check V ∈ {1,...,N} is reachable by N-1 step
def reachable(node, value):
    if value < 0:
        return False
    # print("call ", node, " ", value)
    if node == u:
        return True
    else:
        flag = False
        for ng in A[node]:
            if reachable(ng, value - 1):
                flag = True
                break
        return flag

# 最大の距離
max_v = -1
for n in range(1, N+1):
    if reachable(n, dist[n] + 1):
        max_v = max(dist[n], max_v)
print(max_v - 1)