import std.stdio, std.string, std.conv;
import std.algorithm;
 
void main()
{
    for(string s_; (s_=readln.chomp()).length;)
    {
        auto NK = s_.split.map!(to!int);
        immutable N=NK[0], K=NK[1];
        auto g = new int[][N];
        foreach(_;1..N)
        {
            auto AB = readln.split.map!(x=>x.to!int()-1);
            immutable A=AB[0], B=AB[1];
            g[A]~=B;
            g[B]~=A;
        }
        auto d = new int[N];
        auto r = new int[N]; r[]=true;
        int dfs(int s, int t, int k)
        {
            int m=d[t]=k;
            foreach(v;g[t]) if(v!=s && r[v]) m=max(m,dfs(t,v,k+1));
            return m;
        }
        auto k = dfs(-1,0,0);
        int s=0;
        foreach(int i,v;d) if(v==k){ s=i; break; }
        int c=0;
        while(true)
        {
            k=dfs(-1,s,0);
            if(k<=K) break;
            int[] d1;
            foreach(int i,v;d) if(r[i] && v==k) d1~=i;
            dfs(-1,d1[0],0);
            int[] d2;
            foreach(int i,v;d) if(r[i] && v==k) d2~=i;
            if(d1.length>d2.length) swap(d1,d2);
            c+=d1.length.to!int();
            foreach(v;d1) r[v]=false;
        }
        writeln(c);
    }
}