import sys,heapq
input = sys.stdin.readline
def main():
    n,u,v = map(int,input().split())
    u,v = u-1,v-1

    edge = [[] for _ in range(n)]

    for _ in [0]*(n-1):
        a,b = map(int,input().split())
        edge[a-1].append(b-1)
        edge[b-1].append(a-1)

    #cost:vからの距離
    cost = [0]*n
    new = [v]
    c = 1
    while len(new):
        tank = []
        for e in new:
            for go in edge[e]:
                if go != v and cost[go] == 0:
                    cost[go] = c
                    tank.append(go)
        c += 1
        new = tank

    res = 1
    new = set([u])
    while len(new):
        tank = set()
        for e in new:
            for go in edge[e]:
                if cost[go] > res:
                    tank.add(go)
        res += 1
        new = tank
    
    if cost[u]% 2 == 1:
        print(res-2)
    else:
        print(res-1)

if __name__ == '__main__':
    main()