import sys

input = sys.stdin.readline

sys.setrecursionlimit(10 ** 7)



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

AB = [[int(x) for x in input().split()] for _ in range(N-1)]



graph = [[] for _ in range(N+1)]

for a,b in AB:

    graph[a].append(b)

    graph[b].append(a)



def count_nbd(x,R,parent):

    # parentを含まない部分木

    # xを含む、xから半径R内の点の個数を数える

    count = 0

    visited = [False] * (N+1)

    visited[x] = True

    visited[parent] = True

    count += 1

    q = [x]

    for _ in range(R):

        qq = []

        for y in q:

            for z in graph[y]:

                if visited[z]:

                    continue

                visited[z] = True

                qq.append(z)

                count += 1

        q = qq

    return count



if K&1:

    # 辺の中点に中心がある場合

    R = (K-1)//2

    x = max(count_nbd(x,R,y) + count_nbd(y,R,x) for x,y in AB)

else:

    # 頂点が中心

    R = K//2

    x = max(count_nbd(x,R,0) for x in range(1,N+1))



answer = N-x

print(answer)
import sys

read = sys.stdin.buffer.read

readline = sys.stdin.buffer.readline

readlines = sys.stdin.buffer.readlines



from collections import deque



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

m = list(map(int,read().split()))

AB = list(zip(m,m))



graph = [[] for _ in range(N+1)]

for a,b in AB:

    graph[a].append(b)

    graph[b].append(a)



def F(a,b,K):

    INF = 10 ** 9

    if a == b:

        # 中心が1点

        q = deque([a])

        r = K // 2

    else:

        # 中心が辺

        q = deque([a,b])

        r = (K-1)//2

    dist = [INF] * (N+1)

    for x in q:

        dist[x] = 0

    pop = q.popleft; append = q.append

    cnt = len(q)

    while q:

        v = pop()

        dw = dist[v] + 1

        if dw > r:

            break

        for w in graph[v]:

            if dist[w] == INF:

                cnt += 1

                dist[w] = dw

                append(w)

    return N - cnt



if K & 1:

    answer = min(F(a,b,K) for a,b in AB)

else:

    answer = min(F(a,a,K) for a in range(1,N+1))

print(answer)
import sys

input = sys.stdin.readline
sys.setrecursionlimit(10**7)
N, K = list(map(int, input().split()))
AB = [[int(x) for x in input().split()] for _ in range(N - 1)]
graph = [[] for _ in range(N + 1)]
for a, b in AB:
    graph[a].append(b)
    graph[b].append(a)


def count_nbd(x, R, parent):
    # parentを含まない部分木
    # xを含む、xから半径R内の点の個数を数える
    count = 0
    visited = [False] * (N + 1)
    visited[x] = True
    visited[parent] = True
    count += 1
    q = [x]
    for _ in range(R):
        qq = []
        for y in q:
            for z in graph[y]:
                if visited[z]:
                    continue
                visited[z] = True
                qq.append(z)
                count += 1
        q = qq
    return count


if K & 1:
    # 辺の中点に中心がある場合
    R = (K - 1) // 2
    x = max(count_nbd(x, R, y) + count_nbd(y, R, x) for x, y in AB)
else:
    # 頂点が中心
    R = K // 2
    x = max(count_nbd(x, R, 0) for x in range(1, N + 1))
answer = N - x
print(answer)

import sys

read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines
from collections import deque

N, K = list(map(int, readline().split()))
m = list(map(int, read().split()))
AB = list(zip(m, m))
graph = [[] for _ in range(N + 1)]
for a, b in AB:
    graph[a].append(b)
    graph[b].append(a)


def F(a, b, K):
    INF = 10**9
    if a == b:
        # 中心が1点
        q = deque([a])
        r = K // 2
    else:
        # 中心が辺
        q = deque([a, b])
        r = (K - 1) // 2
    dist = [INF] * (N + 1)
    for x in q:
        dist[x] = 0
    pop = q.popleft
    append = q.append
    cnt = len(q)
    while q:
        v = pop()
        dw = dist[v] + 1
        if dw > r:
            break
        for w in graph[v]:
            if dist[w] == INF:
                cnt += 1
                dist[w] = dw
                append(w)
    return N - cnt


if K & 1:
    answer = min(F(a, b, K) for a, b in AB)
else:
    answer = min(F(a, a, K) for a in range(1, N + 1))
print(answer)

-input = sys.stdin.readline -sys.setrecursionlimit(10**7) -N, K = list(map(int, input().split())) -AB = [[int(x) for x in input().split()] for _ in range(N - 1)] +read = sys.stdin.buffer.read +readline = sys.stdin.buffer.readline +readlines = sys.stdin.buffer.readlines +from collections import deque + +N, K = list(map(int, readline().split())) +m = list(map(int, read().split())) +AB = list(zip(m, m)) -def count_nbd(x, R, parent): -    # parentを含まない部分木 -    # xを含む、xから半径R内の点の個数を数える -    count = 0 -    visited = [False] * (N + 1) -    visited[x] = True -    visited[parent] = True -    count += 1 -    q = [x] -    for _ in range(R): -        qq = [] -        for y in q: -            for z in graph[y]: -                if visited[z]: -                    continue -                visited[z] = True -                qq.append(z) -                count += 1 -        q = qq -    return count +def F(a, b, K): +    INF = 10**9 +    if a == b: +        # 中心が1点 +        q = deque([a]) +        r = K // 2 +    else: +        # 中心が辺 +        q = deque([a, b]) +        r = (K - 1) // 2 +    dist = [INF] * (N + 1) +    for x in q: +        dist[x] = 0 +    pop = q.popleft +    append = q.append +    cnt = len(q) +    while q: +        v = pop() +        dw = dist[v] + 1 +        if dw > r: +            break +        for w in graph[v]: +            if dist[w] == INF: +                cnt += 1 +                dist[w] = dw +                append(w) +    return N - cnt -    # 辺の中点に中心がある場合 -    R = (K - 1) // 2 -    x = max(count_nbd(x, R, y) + count_nbd(y, R, x) for x, y in AB) +    answer = min(F(a, b, K) for a, b in AB) -    # 頂点が中心 -    R = K // 2 -    x = max(count_nbd(x, R, 0) for x in range(1, N + 1)) -answer = N - x +    answer = min(F(a, a, K) for a in range(1, N + 1))