#!/usr/bin/env python3
# O(n).
from collections import deque
import sys
 
input = sys.stdin.readline
 
n, k = map(int, input().strip().split())
k -= 1
 
maxn, inf = 10**5, (1 << 30) - 1
g = [[] for _ in range(n)]
 
df_index, df_time = 0, 0
df_poz, tata, subtree_size, depth, df_times, switches = [0] * n, [0] * n, [0] * n, [0] * n, [0] * (2*n), [False] * n
 
for _ in range(n-1):
    a, b = map(int, input().strip().split())
    a -= 1; b -= 1
    g[a].append(b); g[b].append(a)
 
# intoarce toate nodurile din coada bfs-ului care sunt la aceeasi adancime ca k.
queues, pin = [[0], []], 0
 
tata[0], subtree_size[0] = -1, 1
 
while queues[pin] and k not in queues[pin]:
    for nod in queues[pin]:
        for nn in g[nod]:
            # am nevoie de subtree_size doar ca sa determin indexul lui k in bfs(z). astfel calculez subtree_size doar pana la depth[k].
            tata[nn], depth[nn], subtree_size[nn] = nod, 1 + depth[nod], 1 # tata, depth sunt calculate partial aici pana la depth[k] inclusiv.
            if nn != tata[nod]:
                queues[pin^1].append(nn)
    queues[pin] = []
    pin ^= 1
 
# dfs:
stk = [(0, -1, False)] # (nod, tata, is_after) -- is_after e flag, e.g. am procesat copiii sau nu.
 
while stk:
    nod, t, is_after = stk.pop()
 
    if not is_after:
        tata[nod] = t
        if t != -1:
            depth[nod] = 1 + depth[t]
 
        df_poz[nod] = df_index; df_index += 1
        df_times[2*nod] = df_time; df_time += 1
 
        stk.append((nod, t, True))
        stk.extend([(nn, nod, False) for nn in g[nod][::-1] if nn != t]) # adaug invers a.i. pun in varf primul copil din lista.
    else:
        df_times[2*nod+1] = df_time; df_time += 1
        if t != -1:
            subtree_size[t] += subtree_size[nod]
 
nodes_depth_as_k = queues[pin]
ind_k = nodes_depth_as_k.index(k)
ind_last_in_subtree, z, ans_dfs_bfs = ind_k, k, inf
 
while z != -1:
    # calculez pe ce pozitie ar fi k daca incep bfs din z.
    # pozitia e: subtree_size[z] - cate noduri de la aceeasi adancime ca k sunt la dreapta lui k.
    # obs: cu cat merg mai sus in arbore, voi continua sa cuprind nodurile deja numarate + optional altele.
 
    while ind_last_in_subtree + 1 < len(nodes_depth_as_k) and\
        df_times[2*z] < df_times[2*nodes_depth_as_k[ind_last_in_subtree+1]] and\
        df_times[2*nodes_depth_as_k[ind_last_in_subtree+1]+1] < df_times[2*z+1]:
        ind_last_in_subtree += 1
 
    ans_dfs_bfs = min(ans_dfs_bfs, df_poz[z] + subtree_size[z] - (ind_last_in_subtree - ind_k))
 
    switches[z] = True
    z = tata[z]
 
ans_bfs_dfs, bfs_iter = inf, 0
qu = deque([0])
 
while qu:
    nod = qu.popleft()
    bfs_iter += 1
 
    if switches[nod]:
        ans_bfs_dfs = min(ans_bfs_dfs, bfs_iter + df_poz[k] - df_poz[nod])
    for nn in g[nod]:
        if nn != tata[nod]:
            qu.append(nn)
 
print(f"{ans_bfs_dfs}\n{ans_dfs_bfs}")
