#include <iostream>
#include <vector>
#include <fstream>

using namespace std;

typedef long long ll;

struct State {
    ll a[4];
    
    State() 
    {
        a[0] = a[1] = a[2] = a[3] = 0;
    }

    bool get(int i) { return a[i >> 6] & (1LL << (i & 63)); }

    void set(int i) { a[i >> 6] |= 1LL << (i & 63); }

    State& operator|=(const State& s)
    {
        for (int i = 0; i < 4; i++)
            a[i] |= s.a[i];
        return *this;
    }
};

const int N = 250;

int dist[N][N];
int n, k;
vector<State> kills;

bool run(int start, State s, int remain)
{
    if (remain == 0)
        return true;
    for (int i = start; i < n; i++)
    {
        if (!s.get(i))
        {
            State newS = s;
            newS |= kills[i];
            if (run(i + 1, newS, remain - 1))
                return true;
        }
    }
    return false;
}

bool check(int d)
{
    kills = vector<State>(n);
    for (int i = 0; i < n; i++)
        for (int j = 0; j < n; j++)
            if (dist[i][j] < d)
                kills[i].set(j);
    return run(0, State(), k);
}

int main()
{
    ifstream in("defence.in");
    ofstream out("defence.out");
    in >> n >> k;
    for (int i = 0; i < n; i++)
    {
        for (int j = 0; j < n; j++)
            dist[i][j] = n + 1;
        dist[i][i] = 0;
    }
    for (int i = 0; i < n - 1; i++)
    {
        int a, b;
        in >> a >> b;
        a--; b--;
        dist[a][b] = dist[b][a] = 1;
    }
    for (int k = 0; k < n; k++)
        for (int i = 0; i < n; i++)
            for (int j = 0; j < n; j++)
                dist[i][j] = min(dist[i][k] + dist[k][j], dist[i][j]);
    int left = 0;
    int right = n + 1;
    while (left + 1 < right)
    {
        int mid = (left + right) / 2;
        if (check(mid))
            left = mid;
        else
            right = mid;
    }
    out << left << "\n";
}
