n,m=map(int,input().split()) li=[] person=[[] for i inrange(n+1)] person_num=[] for i inrange(n-1): l,r=map(int,input().split()) li.append((l,r)) li.sort(key=lambda x:x[1]) for i inrange(n-1): a=li[i]#(2, 1) person[a[1]].append(a[0]) for i inrange(n,0,-1): iflen(person[i])!=0: for j in person[i]:#[2, 3] person[i]=list(set(person[i]+person[j])) for i inrange(1,n+1): a,b=i,len(person[i]) person_num.append((a,b)) person_num.sort(key=lambda x:x[1],reverse=True) for i in person_num: if i[0]==m: print(person_num.index(i)+1)