import sys
import numpy as np
from scipy.sparse.csgraph import dijkstra
from scipy.sparse import coo_matrix


def get_path(start, goal, pred):
    return get_path_row(start, goal, pred[start])


def get_path_row(start, goal, pred_row):
    path = []
    i = goal
    while i != start and pred_row[i] > 0:
        path.append(i)
        i = pred_row[i]
    if i < 0:
        return []
    path.append(i)
    return path[::-1]


read = sys.stdin.read
N, u, v, *AB = map(int, read().split())

a = AB[::2]
b = AB[1::2]
d = [1] * (N - 1)

graph = coo_matrix((d, (a, b)), shape=(N + 1, N + 1))
takahashi, aoki = dijkstra(graph, directed=False, indices=[u, v])
n = np.where(takahashi < aoki)
print(int(aoki[n].max()) - 1)
