#!/usr/bin/env python3
import sys


def solve(N: int, u: int, v: int, A: "List[int]", B: "List[int]"):
    if u == v:
        return 0
    edges = [[] for _ in range(N)]
    for a, b in zip(A, B):
        edges[a-1].append(b-1)
        edges[b-1].append(a-1)
    t_a = [[float('inf')] * N for _ in range(2)]
    def dfs(n, c, t):
        if t_a[t][n] < float('inf'):
            return
        t_a[t][n] = c
        for nn in edges[n]:
            dfs(nn, c+1, t)
    dfs(u-1, 0, 0)
    dfs(v-1, 0, 1)
    c = max(a for t, a in zip(*t_a) if t < a)
    return c - 1

# Generated by 1.1.6 https://github.com/kyuridenamida/atcoder-tools
def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    N = int(next(tokens))  # type: int
    u = int(next(tokens))  # type: int
    v = int(next(tokens))  # type: int
    A = [int()] * (N - 1)  # type: "List[int]"
    B = [int()] * (N - 1)  # type: "List[int]"
    for i in range(N - 1):
        A[i] = int(next(tokens))
        B[i] = int(next(tokens))
    print(solve(N, u, v, A, B))

def test():
    import doctest
    doctest.testmod()

if __name__ == '__main__':
    #test()
    main()
