import sys
input = sys.stdin.readline
sys.setrecursionlimit(10**9)

def main():
    n, u, v = map(int, input().split())
    u, v = u-1, v-1
    G = [[] for i in range(n)]
    for i in range(n-1):
        a,b = map(int, input().split())
        a,b = a-1,b-1
        G[a].append(b)
        G[b].append(a)

    def dfs(c,p,d):
        dep[c] = d
        for to in G[c]:
            if to != p:
                dfs(to, c, d+1)

    dep = [0]*n
    dfs(v, -1, 0)
    a = dep[:]
    dfs(u, -1, 0)
    b = dep

    ans = 0
    for i in range(n):
        if b[i] >= a[i]:
            continue
        tmp = 0
        d = b[i]
        if d != 0:
            tmp = 2*d
            aoki = d
        else:
            aoki = 0
        tak = a[i]
        m = tak-aoki
        if m%2==1:
            tmp += 2*m -1
        else:
            tmp += 2*(m-1)
        ans = max(ans, tmp)
    print(ans//2)

if __name__ == "__main__":
    main()
