import std.stdio, std.array, std.string, std.conv, std.algorithm;
import std.typecons, std.range, std.random, std.math, std.container;
import std.numeric, std.bigint, core.bitop;

int N, K;
int[][] edge;

int dfs(int n, int prev, int d) {
    int ret = 1;
    if (d == 0) return ret;

    foreach (m; edge[n]) {
        if (m == prev) continue;
        ret += dfs(m, n, d-1);
    }
    return ret;
}

int dfs2(int n, int prev, int d) {
    if (d == 1 && prev == -1) return edge[n].length.to!int;
    else if (d == 1) return edge[n].length.to!int - 1;

    int ret = 0;
    foreach (m; edge[n]) {
        if (m == prev) continue;
        ret = max(ret, dfs2(m, n, d-1));
    }

    return ret;
}


void main() {
    auto s = readln.split.map!(to!int).array;
    N = s[0];
    K = s[1];
    edge = new int[][](N);
    foreach (i; 0..N-1) {
        s = readln.split.map!(to!int).array;
        edge[s[0]-1] ~= s[1]-1;
        edge[s[1]-1] ~= s[0]-1;
    }

    int ans = 1 << 29;
    foreach (i; 0..N) { // 各頂点を木の中心と仮定
        int tmp = dfs(i, -1, K/2);
        if (K % 2 == 1) tmp += dfs2(i, -1, K/2+1);
        ans = min(ans, N-tmp);
    }

    writeln(K == 1 ? N-2 : ans);
}
