from sys import setrecursionlimit

setrecursionlimit(1000000)

def calc_dist(b,h,dist,E,D,ne):

	D[dist] += 1

	for nxt in E[h]:

		if nxt == b or nxt == ne:

			continue

		calc_dist(h,nxt,dist+1,E,D,ne) 



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 i in range(N):

			D = [0]*N

			calc_dist(-1,i,0,E,D,-1)

			for j in range(rad):

				D[rad-j-1] += D[rad-j]

			ans = min(N-D[0],ans)

	else:

		for a,b in pairs:

			D1 = [0]*N

			D2 = [0]*N

			calc_dist(-1,a,0,E,D1,b)

			calc_dist(-1,b,0,E,D2,a)

			for j in range(rad):

				D1[rad-j-1] += D1[rad-j]

				D2[rad-j-1] += D2[rad-j]

			ans = min(N-D1[0]-D2[0],ans)

	print(ans)



solve()
from sys import setrecursionlimit

setrecursionlimit(100000)

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

	cnt = 1

	if dist < rad:

		for nxt in E[h]:

			if nxt == b or nxt == ne:

				continue

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

	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,-1))

	else:

		for c1,c2 in pairs:

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

	print(ans)

solve()
from sys import setrecursionlimit

setrecursionlimit(1000000)


def calc_dist(b, h, dist, E, D, ne):
    D[dist] += 1
    for nxt in E[h]:
        if nxt == b or nxt == ne:
            continue
        calc_dist(h, nxt, dist + 1, E, D, ne)


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 i in range(N):
            D = [0] * N
            calc_dist(-1, i, 0, E, D, -1)
            for j in range(rad):
                D[rad - j - 1] += D[rad - j]
            ans = min(N - D[0], ans)
    else:
        for a, b in pairs:
            D1 = [0] * N
            D2 = [0] * N
            calc_dist(-1, a, 0, E, D1, b)
            calc_dist(-1, b, 0, E, D2, a)
            for j in range(rad):
                D1[rad - j - 1] += D1[rad - j]
                D2[rad - j - 1] += D2[rad - j]
            ans = min(N - D1[0] - D2[0], ans)
    print(ans)


solve()

from sys import setrecursionlimit

setrecursionlimit(100000)


def rad_reach(b, h, dist, E, rad, ne):
    cnt = 1
    if dist < rad:
        for nxt in E[h]:
            if nxt == b or nxt == ne:
                continue
            cnt += rad_reach(h, nxt, dist + 1, E, rad, ne)
    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, -1))
    else:
        for c1, c2 in pairs:
            ans = min(
                ans,
                N - rad_reach(-1, c1, 0, E, rad, c2) - rad_reach(-1, c2, 0, E, rad, c1),
            )
    print(ans)


solve()

-setrecursionlimit(1000000) +setrecursionlimit(100000) -def calc_dist(b, h, dist, E, D, ne): -    D[dist] += 1 -    for nxt in E[h]: -        if nxt == b or nxt == ne: -            continue -        calc_dist(h, nxt, dist + 1, E, D, ne) +def rad_reach(b, h, dist, E, rad, ne): +    cnt = 1 +    if dist < rad: +        for nxt in E[h]: +            if nxt == b or nxt == ne: +                continue +            cnt += rad_reach(h, nxt, dist + 1, E, rad, ne) +    return cnt -        for i in range(N): -            D = [0] * N -            calc_dist(-1, i, 0, E, D, -1) -            for j in range(rad): -                D[rad - j - 1] += D[rad - j] -            ans = min(N - D[0], ans) +        for c in range(N): +            ans = min(ans, N - rad_reach(-1, c, 0, E, rad, -1)) -        for a, b in pairs: -            D1 = [0] * N -            D2 = [0] * N -            calc_dist(-1, a, 0, E, D1, b) -            calc_dist(-1, b, 0, E, D2, a) -            for j in range(rad): -                D1[rad - j - 1] += D1[rad - j] -                D2[rad - j - 1] += D2[rad - j] -            ans = min(N - D1[0] - D2[0], ans) +        for c1, c2 in pairs: +            ans = min( +                ans, +                N - rad_reach(-1, c1, 0, E, rad, c2) - rad_reach(-1, c2, 0, E, rad, c1), +            )