class NTree(object): def __init__(self): self.count = 0 def constructor(self,N, K, edges, num): self.N = int(N) self.K = int(K) self.edges = edges self.num = num if self.N < self.K: print(-1) exit() def run(self): sorted_num = dict(sorted(self.num.items(), key=lambda x:x[0])) K = self.K for key, value in sorted_num.items(): if value >= K: self.count += K break else: self.count += value K = K - value print(self.count-1) if __name__=="__main__": N, K = input().split(" ") edges= list() num = dict() for i in range(1, int(N)): edge = list(map(int, input().split(" "))) edges.append(edge) if not edge[0] in num.keys(): num[edge[0]] = 1 else: num[edge[0]] += 1 func = NTree() func.constructor(N=N, K=K, edges=edges, num=num) func.run()