from collections import deque



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

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

E = []

for i in range(N-1):

    a, b = list(map(int, input().split()))

    a, b = a-1, b-1

    T[a].append(b)

    T[b].append(a)

    E.append((a, b))





def dfs(n):

    visited = [False] * N

    stack = [[n, 0]]

    longest = [-1, -1]



    while stack:

        node, weight = stack.pop()

        if visited[node]:

            continue

        visited[node] = True

        if longest[1] < weight:

            longest = [node, weight]



        for n in T[node]:

            if not visited[n]:

                stack.append([n, weight + 1])



    return longest





def bfs(n):

    visited = [False] * N

    dist = [0] * N

    queue = deque([n])

    while queue:

        node = queue.pop()

        if visited[node]:

            continue

        visited[node] = True

        for n in T[node]:

            if not visited[n]:

                dist[n] = dist[node] + 1

                queue.appendleft(n)

    return dist





xn, xw = dfs(0)

yn, yw = dfs(xn)

diameter = yw



d = bfs(0)

ans = float('inf')

if K % 2 == 0:

    # 全ての頂点について全探索

    for i in range(N):

        dist = bfs(i)

        ans = min(ans, len(list([x for x in dist if K / 2 < x])))

else:

    # 全ての辺について全探索

    for a, b in E:

        dist1 = bfs(a)

        dist2 = bfs(b)

        dist = [min(d1, d2) for d1, d2 in zip(dist1, dist2)]

        ans = min(ans, len(list([x for x in dist if (K-1) / 2 < x])))



print(ans)

from collections import deque



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

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

E = []

for i in range(N-1):

    a, b = list(map(int, input().split()))

    a, b = a-1, b-1

    T[a].append(b)

    T[b].append(a)

    E.append((a, b))





def bfs(n):

    visited = [False] * N

    dist = [0] * N

    queue = deque([n])

    while queue:

        node = queue.pop()

        if visited[node]:

            continue

        visited[node] = True

        for n in T[node]:

            if not visited[n]:

                dist[n] = dist[node] + 1

                queue.appendleft(n)

    return dist





dist = []

for i in range(N):

    dist.append(bfs(i))



ans = float('inf')

if K % 2 == 0:

    # 全ての頂点について全探索

    for i in range(N):

        ans = min(ans, len(list([x for x in dist[i] if K / 2 < x])))

else:

    # 全ての辺について全探索

    for a, b in E:

        adist = [min(d1, d2) for d1, d2 in zip(dist[a], dist[b])]

        ans = min(ans, len(list([x for x in adist if (K-1) / 2 < x])))



print(ans)

from collections import deque

N, K = list(map(int, input().split()))
T = [[] for i in range(N)]
E = []
for i in range(N - 1):
    a, b = list(map(int, input().split()))
    a, b = a - 1, b - 1
    T[a].append(b)
    T[b].append(a)
    E.append((a, b))


def dfs(n):
    visited = [False] * N
    stack = [[n, 0]]
    longest = [-1, -1]
    while stack:
        node, weight = stack.pop()
        if visited[node]:
            continue
        visited[node] = True
        if longest[1] < weight:
            longest = [node, weight]
        for n in T[node]:
            if not visited[n]:
                stack.append([n, weight + 1])
    return longest


def bfs(n):
    visited = [False] * N
    dist = [0] * N
    queue = deque([n])
    while queue:
        node = queue.pop()
        if visited[node]:
            continue
        visited[node] = True
        for n in T[node]:
            if not visited[n]:
                dist[n] = dist[node] + 1
                queue.appendleft(n)
    return dist


xn, xw = dfs(0)
yn, yw = dfs(xn)
diameter = yw
d = bfs(0)
ans = float("inf")
if K % 2 == 0:
    # 全ての頂点について全探索
    for i in range(N):
        dist = bfs(i)
        ans = min(ans, len(list([x for x in dist if K / 2 < x])))
else:
    # 全ての辺について全探索
    for a, b in E:
        dist1 = bfs(a)
        dist2 = bfs(b)
        dist = [min(d1, d2) for d1, d2 in zip(dist1, dist2)]
        ans = min(ans, len(list([x for x in dist if (K - 1) / 2 < x])))
print(ans)

from collections import deque

N, K = list(map(int, input().split()))
T = [[] for i in range(N)]
E = []
for i in range(N - 1):
    a, b = list(map(int, input().split()))
    a, b = a - 1, b - 1
    T[a].append(b)
    T[b].append(a)
    E.append((a, b))


def bfs(n):
    visited = [False] * N
    dist = [0] * N
    queue = deque([n])
    while queue:
        node = queue.pop()
        if visited[node]:
            continue
        visited[node] = True
        for n in T[node]:
            if not visited[n]:
                dist[n] = dist[node] + 1
                queue.appendleft(n)
    return dist


dist = []
for i in range(N):
    dist.append(bfs(i))
ans = float("inf")
if K % 2 == 0:
    # 全ての頂点について全探索
    for i in range(N):
        ans = min(ans, len(list([x for x in dist[i] if K / 2 < x])))
else:
    # 全ての辺について全探索
    for a, b in E:
        adist = [min(d1, d2) for d1, d2 in zip(dist[a], dist[b])]
        ans = min(ans, len(list([x for x in adist if (K - 1) / 2 < x])))
print(ans)

- - -def dfs(n): -    visited = [False] * N -    stack = [[n, 0]] -    longest = [-1, -1] -    while stack: -        node, weight = stack.pop() -        if visited[node]: -            continue -        visited[node] = True -        if longest[1] < weight: -            longest = [node, weight] -        for n in T[node]: -            if not visited[n]: -                stack.append([n, weight + 1]) -    return longest -xn, xw = dfs(0) -yn, yw = dfs(xn) -diameter = yw -d = bfs(0) +dist = [] +for i in range(N): +    dist.append(bfs(i)) -        dist = bfs(i) -        ans = min(ans, len(list([x for x in dist if K / 2 < x]))) +        ans = min(ans, len(list([x for x in dist[i] if K / 2 < x]))) -        dist1 = bfs(a) -        dist2 = bfs(b) -        dist = [min(d1, d2) for d1, d2 in zip(dist1, dist2)] -        ans = min(ans, len(list([x for x in dist if (K - 1) / 2 < x]))) +        adist = [min(d1, d2) for d1, d2 in zip(dist[a], dist[b])] +        ans = min(ans, len(list([x for x in adist if (K - 1) / 2 < x])))