from collections import deque

def rad_reach(bfr,h,rest,E):

	cnt = 0

	Q = deque([(bfr,h,rest)])

	while Q:

		cnt += 1

		bfr,h,rest = Q.popleft()

		if rest > 0:

			for nxt in E[h]:

				if nxt == bfr:

					continue

				Q.append((h,nxt,rest-1))

	return cnt

def solve():

	N,K = list(map(int,input().split()))

	pairs = []

	E = [[] for i in range(N)]

	for i in range(N-1):

		p = [int(x)-1 for x in input().split()]

		pairs.append(p)

		E[p[0]].append(p[1])

		E[p[1]].append(p[0])

	ans = N

	rad = K/2

	if K % 2 == 0:

		for c in range(N):

			ans = min(ans,N-rad_reach(-1,c,rad,E))

	else:

		for c1,c2 in pairs:

			ans = min(ans,N-rad_reach(c2,c1,rad,E)-rad_reach(c1,c2,rad,E))

	print(ans)

solve()
from sys import setrecursionlimit

setrecursionlimit(100000)

def rad_reach(b,h,dist,E,rad):

	cnt = 1

	if dist < rad:

		for nxt in E[h]:

			if nxt == b:

				continue

			cnt += rad_reach(h,nxt,dist+1,E,rad) 

	return cnt

def solve():

	N,K = list(map(int,input().split()))

	pairs = []

	E = [[] for i in range(N)]

	for i in range(N-1):

		a,b = [int(x)-1 for x in input().split()]

		E[a].append(b)

		E[b].append(a)

		pairs.append((a,b))

	ans = N

	rad = K/2

	if K % 2 == 0:

		for c in range(N):

			ans = min(ans,N-rad_reach(-1,c,0,E,rad))

	else:

		for c1,c2 in pairs:

			ans = min(ans,N-rad_reach(c2,c1,0,E,rad)-rad_reach(c1,c2,0,E,rad))

	print(ans)

solve()
from collections import deque


def rad_reach(bfr, h, rest, E):
    cnt = 0
    Q = deque([(bfr, h, rest)])
    while Q:
        cnt += 1
        bfr, h, rest = Q.popleft()
        if rest > 0:
            for nxt in E[h]:
                if nxt == bfr:
                    continue
                Q.append((h, nxt, rest - 1))
    return cnt


def solve():
    N, K = list(map(int, input().split()))
    pairs = []
    E = [[] for i in range(N)]
    for i in range(N - 1):
        p = [int(x) - 1 for x in input().split()]
        pairs.append(p)
        E[p[0]].append(p[1])
        E[p[1]].append(p[0])
    ans = N
    rad = K / 2
    if K % 2 == 0:
        for c in range(N):
            ans = min(ans, N - rad_reach(-1, c, rad, E))
    else:
        for c1, c2 in pairs:
            ans = min(ans, N - rad_reach(c2, c1, rad, E) - rad_reach(c1, c2, rad, E))
    print(ans)


solve()

from sys import setrecursionlimit

setrecursionlimit(100000)


def rad_reach(b, h, dist, E, rad):
    cnt = 1
    if dist < rad:
        for nxt in E[h]:
            if nxt == b:
                continue
            cnt += rad_reach(h, nxt, dist + 1, E, rad)
    return cnt


def solve():
    N, K = list(map(int, input().split()))
    pairs = []
    E = [[] for i in range(N)]
    for i in range(N - 1):
        a, b = [int(x) - 1 for x in input().split()]
        E[a].append(b)
        E[b].append(a)
        pairs.append((a, b))
    ans = N
    rad = K / 2
    if K % 2 == 0:
        for c in range(N):
            ans = min(ans, N - rad_reach(-1, c, 0, E, rad))
    else:
        for c1, c2 in pairs:
            ans = min(
                ans, N - rad_reach(c2, c1, 0, E, rad) - rad_reach(c1, c2, 0, E, rad)
            )
    print(ans)


solve()

-from collections import deque +from sys import setrecursionlimit + +setrecursionlimit(100000) -def rad_reach(bfr, h, rest, E): -    cnt = 0 -    Q = deque([(bfr, h, rest)]) -    while Q: -        cnt += 1 -        bfr, h, rest = Q.popleft() -        if rest > 0: -            for nxt in E[h]: -                if nxt == bfr: -                    continue -                Q.append((h, nxt, rest - 1)) +def rad_reach(b, h, dist, E, rad): +    cnt = 1 +    if dist < rad: +        for nxt in E[h]: +            if nxt == b: +                continue +            cnt += rad_reach(h, nxt, dist + 1, E, rad) -        p = [int(x) - 1 for x in input().split()] -        pairs.append(p) -        E[p[0]].append(p[1]) -        E[p[1]].append(p[0]) +        a, b = [int(x) - 1 for x in input().split()] +        E[a].append(b) +        E[b].append(a) +        pairs.append((a, b)) -            ans = min(ans, N - rad_reach(-1, c, rad, E)) +            ans = min(ans, N - rad_reach(-1, c, 0, E, rad)) -            ans = min(ans, N - rad_reach(c2, c1, rad, E) - rad_reach(c1, c2, rad, E)) +            ans = min( +                ans, N - rad_reach(c2, c1, 0, E, rad) - rad_reach(c1, c2, 0, E, rad) +            )