import std.stdio;
import std.string;
import std.conv;
import std.typecons;
import std.algorithm;
import std.functional;
import std.bigint;
import std.numeric;
import std.array;
import std.math;
import std.range;
import std.container;
import std.ascii;

void times(int n, void delegate() pred) {
    foreach(i; 0..n) pred();
}
T[] rep(T)(int n, T delegate() pred) {
    T[] res = new T[n];
    foreach(ref e; res) e = pred();
    return res;
}

int INF = 1<<25;
Vertex[] vertices;
Vertex[2] vPair;
void main() {
    int N, K;
    readf("%d %d\n", &N, &K);

    vertices = new Vertex[N];
    foreach(i; 0..N) vertices[i] = new Vertex(i);

    (N-1).times({
        int a, b;
        readf("%d %d\n", &a, &b);
        a--; b--;
        vertices[a].edges ~= Edge(vertices[a], vertices[b]);
        vertices[b].edges ~= Edge(vertices[b], vertices[a]);
    });

    int m = INF;
    Vertex v = vertices.front;
    foreach(i; 0..N-1) {
        if (solveDiameter(v) <= K) {
            writeln(i);
            break;
        }

        if (vPair[0].prev is null) {
            Vertex v1 = vPair[0].next;
            Vertex v2 = vPair[1].prev;
            int c1, c2;
            while(true) {
                c1 = v1.edges.count!(e => !e.end.flag).to!int;
                c2 = v2.edges.count!(e => !e.end.flag).to!int;
                if (c1 !is c2) break;
                if (v1.next is null || v2.prev is null) break;
                v1 = v1.next;
                v2 = v2.prev;
            }
            if (c1 < c2) {
                vPair[0].flag = false;
                v = vPair[0].next;
            } else {
                vPair[1].flag = false;
                v = vPair[1].prev;
            }
        } else {
            Vertex v1 = vPair[0].prev;
            Vertex v2 = vPair[1].next;
            int c1, c2;
            while(true) {
                c1 = v1.edges.count!(e => !e.end.flag).to!int;
                c2 = v2.edges.count!(e => !e.end.flag).to!int;
                if (c1 !is c2) break;
                if (v1.prev is null || v2.next is null) break;
                v1 = v1.prev;
                v2 = v2.next;
            }
            if (c1 < c2) {
                vPair[0].flag = false;
                v = vPair[0].prev;
            } else {
                vPair[1].flag = false;
                v = vPair[1].next;
            }
        }
    }
}

void clear() {
    foreach(ref v; vertices) {
        v.visited = false;
        v.prev = null;
        v.next = null;
    }
}

int solveDiameter(Vertex start) {
    int m;
    foreach(i; 0..2) {
        clear();
        m = 0;
        start.depth = 0;
        auto list = DList!(Vertex)(start);
        while (!list.empty) {
            Vertex v = list.front;
            assert(v.flag);
            v.visited = true;
            if (v.depth > m) {
                m = v.depth;
                start = v;
            }
            list.removeFront;
            v.edges.each!((e) {
                if (e.end.visited || !e.end.flag) return;
                list.insertBack(e.end);
                e.end.depth = v.depth+1;
                e.end.prev = v;
            });
        }
        Vertex v = start;
        while(v.prev !is null) {
            v.prev.next = v;
            v = v.prev;
        }
        vPair[i] = start;
    }
    return m;
}

class Vertex{
    size_t index;
    Edge[] edges;
    this(size_t index) {
        this.index = index;
        this.flag = true;
    }

    bool flag;
    bool visited;
    int depth;
    Vertex prev, next;
}

struct Edge {
    Vertex start, end;
}
