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 bfs_fill(G, N, start, du, INF, terminal):
    visited = [-1 for i in range(N+1)]
    visited[start] = 1
    D = [x for x in du] 
    D[start] = INF
    q = deque()
    q.appendleft(start)
    while(len(q) > 0):
        s = q.pop()
        for i in range(len(G[s])):
            t = G[s][i]
            if visited[t] == -1:
                visited[t] = 1
                if D[t] == terminal:
                    return D
                D[t] = INF
                q.appendleft(t)
    return D


def solve(N, u, v, G, INF=-1000000):
    du = bfs(G, N, u, INF)
    max_depth = (du[v] - du[u] - 1) // 2
    du2 = bfs_fill(G, N, v, du, INF, max_depth)
    return max(du2) + (du[v] - du[u] + 1) % 2


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