from collections import deque from copy import copy N,K = map(int,input().split()) g = [[] for _ in range(N)] for _ in range(N-1): a,b = map(int,input().split()) a -= 1 b -= 1 g[a].append(b) g[b].append(a) summary = [0]*N summary[0] = 1 que = deque([(0,K-1,0,summary,[False]*N)]) ans = 10**18 while que: node_f,coin,count,rec,visited = que.popleft() if coin == 0: ans = min(ans,count) elif coin < 0: continue for node_t in g[node_f]: if not visited[node_t]: c = coin r = rec.copy() v = visited.copy() v[node_t] = True if r[node_t] == 0: r[node_t] += 1 c -= 1 que.append((node_t,c,count+1,r,v)) if ans == 10**18: ans = -1 print(ans)