#include <iostream>
#include <cstdio>
#include <string>
#include <sstream>
#include <vector>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <cmath>
#include <algorithm>
#include <cstring>
#include <ctime>
#include <cassert>
#include <unordered_map>
using namespace std;
#define pb push_back
#define mp make_pair
#define pii pair<int,int>
#define vi vector<int>
#define vpii vector<pii>
#define SZ(x) ((int)(x.size()))
#define fi first
#define se second
#define FOR(i,n) for(int (i)=0;(i)<(n);++(i))
#define FORI(i,n) for(int (i)=1;(i)<=(n);++(i))
#define IN(x,y) ((y).find((x))!=(y).end())
#define ALL(t) t.begin(),t.end()
#define FOREACH(i,t) for (typeof(t.begin()) i=t.begin(); i!=t.end(); i++)
#define REP(i,a,b) for(int (i)=(a);(i)<=(b);++i)
#define REPD(i,a,b) for(int (i)=(a); (i)>=(b);--i)
#define REMAX(a,b) (a)=max((a),(b));
#define REMIN(a,b) (a)=min((a),(b));
const int N = 5e5 ;
vi g[ N] ;
unordered_map< int ,int > l_sub[ N] , l_path[ N] ;
int sub_max[ N] ,m_path[ N] ;
vector< pii > ans;
void dfs1( int v, int p)
{
int n = g[ v] .size ( ) ;
vector< int > child;
for ( int i = 0 ; i< n; i++ )
{
int c = g[ v] [ i] ;
if ( c== p) continue ;
dfs1( c,v) ;
child.pb ( c) ;
m_path[ v] = max( m_path[ v] , m_path[ c] + 1 ) ;
}
int tot = 0 ;
for ( int i = 0 ; i< child.size ( ) ; i++ )
{
sub_max[ v] = max( sub_max[ child[ i] ] ,sub_max[ v] ) ;
tot + = m_path[ child[ i] ] + 1 ;
sub_max[ v] = max( tot,sub_max[ v] ) ;
}
if ( child.size ( ) == 2 )
{
l_path[ v] [ child[ 0 ] ] = m_path[ child[ 1 ] ] + 1 ;
l_path[ v] [ child[ 1 ] ] = m_path[ child[ 0 ] ] + 1 ;
l_sub[ v] [ child[ 0 ] ] = max( sub_max[ child[ 1 ] ] , m_path[ child[ 1 ] ] + 1 ) ;
l_sub[ v] [ child[ 1 ] ] = max( sub_max[ child[ 0 ] ] , m_path[ child[ 0 ] ] + 1 ) ;
}
}
void dfs2( int v, int p, int lup, int bup, int k)
{
if ( v! = 1 )
{
lup = lup + 1 ;
bup = max( bup,lup) ;
}
int n = g[ v] .size ( ) ;
for ( int i = 0 ; i< n; i++ )
{
int c = g[ v] [ i] ;
if ( c== p) continue ;
int d1 = sub_max[ c] ;
int d2 = max( l_sub[ v] [ c] , lup + l_path[ v] [ c] ) ;
if ( abs ( d1- d2) < k)
{
//cout<<"Found "<<v<<"->"<<c<<" dia of child = "<<d1<<" dia of upper = "<<d2<<" lup = "<<lup<<" l_sub[v][c] = "<<l_sub[v][c]<<endl;
cout << "Found " << v<< "->" << c<< " dia of child = " << d1<< " dia of upper = " << d2<< endl;
}
//bup = max( bup, d2 );
//lup = max( lup, l_path[v][c] );
dfs2( c,v,max( lup,l_path[ v] [ c] ) ,max( bup,d2) ,k) ;
}
}
int main( )
{
int n,m,u,v,k;
cin >> n>> k;
for ( int i= 0 ; i< n- 1 ; i++ )
{
cin >> u>> v;
g[ u] .pb ( v) ;
g[ v] .pb ( u) ;
}
dfs1( 1 ,0 ) ;
dfs2( 1 ,0 ,0 ,0 ,k) ;
// for(int i =1;i<=n;i++)
// {
// cout<<i<<" sub_max = "<<sub_max[i]<<" m_path = "<<m_path[i]<<endl;
// }
return 0 ;
}
I2luY2x1ZGUgPGlvc3RyZWFtPgojaW5jbHVkZSA8Y3N0ZGlvPgojaW5jbHVkZSA8c3RyaW5nPgojaW5jbHVkZSA8c3N0cmVhbT4gCiNpbmNsdWRlIDx2ZWN0b3I+CiNpbmNsdWRlIDxzZXQ+CiNpbmNsdWRlIDxtYXA+CiNpbmNsdWRlIDxxdWV1ZT4KI2luY2x1ZGUgPHN0YWNrPgojaW5jbHVkZSA8Y21hdGg+CiNpbmNsdWRlIDxhbGdvcml0aG0+CiNpbmNsdWRlIDxjc3RyaW5nPgojaW5jbHVkZSA8Y3RpbWU+CiNpbmNsdWRlIDxjYXNzZXJ0PgojaW5j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