import collections, sys sys.setrecursionlimit(1000000) n, k = map(int, input().split()) nxts = collections.defaultdict(list) for _ in range(n - 1): a, b = map(int, input().split()) a -= 1 b -= 1 nxts[a].append(b) nxts[b].append(a) if n < k: print(-1) exit(0) childs = {} def f(parent, current): if current in childs: return childs[current] v = 1 for nxt in nxts[current]: if nxt != parent: v += f(current, nxt) childs[current] = v return v f(-1, 0) def g(parent, current, coin): if coin <= len(nxts[current]): return 1 ans = 1 for nxt in sorted(filter(lambda nxt: nxt != parent, nxts[current]), key=lambda child: len(nxts[child]), reverse=True): if coin <= childs[nxt]: ans += g(current, nxt, coin) break ans += g(current, nxt, childs[nxt]) coin -= childs[nxt] return ans print(g(-1, 0, k))