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


void main() {
    int n, k;
    scan(n, k);

    auto adj = new int[][](n, 0);
    foreach (i ; 0 .. n-1) {
        int ai, bi;
        scan(ai, bi);
        ai--, bi--;
        adj[ai] ~= bi;
        adj[bi] ~= ai;
    }

    auto tot = new int[](n + 1);
    auto sbt = new int[][](n, n + 1);

    void dfscnt(int v, int p, int sb, int depth) {
        foreach (u ; adj[v]) {
            if (u == p) continue;
            tot[depth]++;
            sbt[sb][depth]++;
            dfscnt(u, v, sb, depth + 1);
        }
    }

    foreach (u ; adj[0]) {
        tot[1]++;
        sbt[u][1]++;
        dfscnt(u, 0, u, 2);
    }

    foreach_reverse (i ; 0 .. n) {
        tot[i] += tot[i+1];
    }

    foreach (v ; 0 .. n) {
        foreach_reverse (i ; 0 .. n) {
            sbt[v][i] += sbt[v][i+1];
        }
    }

    debug {
        writeln("tot");
        writeln(tot);
        writeln;
        writefln("%(%s\n%)", sbt);
    }

    int ans = 1<<30;

    foreach (u ; adj[0]) {
        foreach (d ; 0 .. k + 1) {
            int tmp;
            tmp += tot[k - d + 1];
            tmp -= sbt[u][k - d + 1];
            tmp += sbt[u][d + 1];
            ans = min(ans, tmp);
        }
    }

    writeln(ans);
}










































void scan(T...)(ref T args) {
    import std.stdio : readln;
    import std.algorithm : splitter;
    import std.conv : to;
    import std.range.primitives;

    auto line = readln().splitter();
    foreach (ref arg; args) {
        arg = line.front.to!(typeof(arg));
        line.popFront();
    }
    assert(line.empty);
}



void fillAll(R, T)(ref R arr, T value) {
    static if (is(typeof(arr[] = value))) {
        arr[] = value;
    }
    else {
        foreach (ref e; arr) {
            fillAll(e, value);
        }
    }
}
