n,u,v = map(int,input().split())

hen = [[] for i in range(n)]
for i in range(n-1):
    x,y = map(int,input().split())
    hen[x-1].append(y)
    hen[y-1].append(x)

u_que = [u]
v_que = [v]
long = 0
u_visit = []
u_visitset = [u]
v_visit = []
v_visitset = [v]

for i in range(n-1):
    u_visit.append(u_que)
    u_que_tmp = []
    for j in u_que:
        for k in hen[j-1]:
            u_que_tmp.append(k)
    set(u_que_tmp)
    list(u_que_tmp)
    tmp = []
    for j in u_que_tmp:
        if j not in u_visitset:
            tmp.append(j)
            u_visitset.append(j)           
    u_que = tmp

    v_visit.append(v_que)
    v_que_tmp = []
    for j in v_que:
        for k in hen[j-1]:
            v_que_tmp.append(k)
    set(v_que_tmp)
    list(v_que_tmp)
    tmp = []
    for j in v_que_tmp:
        if j not in v_visitset:
            tmp.append(j)
            v_visitset.append(j)
    v_que = tmp

#print(u_visit,v_visit)
#print(u_visitset,v_visitset)

flag = False
x = len(v_visit)
for i in range(1,len(v_visit)):
    if v_visit[-1*i] == []:
        x -= 1
    else:
        break

for i in range(1,n):
    ans = x - i
    if flag:
        break
    for j in v_visit[-1*i]:
        if flag:
            break
        for k in u_visit[:-1*i]:
            if j in k:
                check = k
                flag = True
                break
flag = False
odd = 0
for i in range(n-1):
    if flag:
        break
    for j in v_visit[i]:
        if u == j:
            if i % 2 == 0:
                odd = 1
                flag = True
                break
            else:
                odd = 0
                flag = True
                break
#print(x,odd,ans)
ans += odd
print(ans)
            


