import sys
n,r=map(int, sys.stdin.readline().split())
graph=[[0 for _ in range(110)] for _ in range(110)]
visited=[False] * 110
cnt=0
maxCnt=0
def dfs(node):
global cnt
global maxCnt
if cnt>maxCnt: maxCnt=cnt
visited[node]=True
for i in range(n):
if (graph[node][i]==1) and visited[i]==False:
cnt+=1
dfs(i)
cnt-=1
if __name__=='__main__':
result = 0
for i in range(n-1):
a, b = map(int, sys.stdin.readline().split())
graph[a][b] = 1
graph[b][a] = 1
dfs(r)
print(maxCnt)