//+-------------------------------------+
//|     By   qwer_zcc                   |
//|     Date 22/06/2014                 |
//+-------------------------------------+
#include <iostream>
#include <cstdio>
#include <cstring>
#include <cstdlib>
#include <algorithm>
#include <vector>
#include <cmath>
#include <set>
#include <map>
#include <list>
#include <queue>
#include <deque>
#include <stack>
#define INF 1000000000
#define LL long long
#define uLL unsigned long long
#define uint unsigned int
#define D double
#define LD long double
#define rep(i,a,b) for (int i=a;i<=b;i++)
#define dep(i,a,b) for (int i=a;i>=b;i--)
#define M(a) memset(a,0,sizeof(a));
#define Chen(a,b,c) int((LL)(a)*(LL)(b)%(LL)(c))
#define pb push_back
#define mp make_pair
#define ins insert
#define ps push
#define Pi M_PI
using namespace std;
template<class T> inline T abs(T &a) {return a>0?a:-a;}
template<class T> inline T min(T &a,T &b) {return a<b?a:b;}
template<class T> inline T max(T &a,T &b) {return a>b?a:b;}
inline void read(int &x)
{
	char ch;
	while ((ch=getchar()) && !(ch>='0' && ch<='9'));x=ch-'0';
	while ((ch=getchar()) && (ch>='0' && ch<='9')) x=x*10+ch-'0';
}
struct point
{
	int x,y;
	point() {}
	point(int _x,int _y) : x(_x),y(_y) {}
} ;
const int N=120000;
vector<int>E[N];
int dep[N],gs[N],Cnt[N],n,d1,k,p0;
void dfs(int w,int Fa)
{
	dep[w]=dep[Fa]+1;
	gs[dep[w]]++;
	d1=max(d1,dep[w]);
	for (int i=0;i<E[w].size();i++)
	if (E[w][i]!=Fa) dfs(E[w][i],w);
}
int main()
{
	//freopen("D.in","r",stdin);
	scanf("%d%d%d",&n,&k,&p0);int x,y;
	rep(i,1,n-1)
	{
		scanf("%d%d",&x,&y);
		E[x].pb(y);E[y].pb(x);
	}
	dfs(1,0);
	int d2=d1,zcnt=0,ans=0;
	while (d2>1)
	{
		while (d2>1 && p0>=(d1-d2))
		{
			if (d1==d2)
			{
				zcnt+=gs[d2]-Cnt[d2];
				Cnt[d2]=gs[d2];
				d2--;
				continue;
			}
			zcnt+=min(p0/(d1-d2),gs[d2]-Cnt[d2]);
			Cnt[d2]+=min(p0/(d1-d2),gs[d2]-Cnt[d2]);
			d2--;
		}
		ans=max(ans,zcnt);
		if (d2==1) break;
		p0-=zcnt-Cnt[d1];
		zcnt-=Cnt[d1];
		d1--;
	}
	printf("%d\n",min(ans,k));
}


#include <iostream>
#include <fstream>
#include <sstream>
#include <vector>
#include <algorithm>
#include <set>
#include <map>
#include <queue>
#include <deque>
#include <iomanip>
#include <cmath>
#include <cstdio>
#include <cstring>
#include <list>
#include <bitset>
#include <complex>
#include <climits>
#include <cfloat>
#include <limits>

using namespace std;

typedef long long ll;
typedef long double ld;
typedef pair <int,int> pii;
typedef pair <ll,ll> pLL;

#define FOR(i,a,b) for ( int i(a) ; i < int(b) ; i++)
#define ROF(i,a,b) for ( int i(a) ; i >= int(b) ; i--)
#define FOREACH(i,c) for ( __typeof ( (c).begin() ) i = (c).begin() ; i != (c).end() ; i++ )
#define ALL(c) c.begin() , c.end()
#define UNIQUE(c) (c).resize(unique( ALL(c) ) - (c).begin() )
#define pb push_back
#define mp make_pair
#define X first
#define Y second
#define gcd __gcd
#define bcnt(x) ((__builtin_popcount(x)))

const int MAX_N = 100000 + 20;
vector <int> adj[MAX_N];
deque <pii> node;
int n , k , p;
int ans;

int cmp ( const pii &a , const pii &b ){
	return a.Y < b.Y;
}

void dfs ( int v , int lvl , int Par = -1 ){
	node.pb( mp(v,lvl) );
	FOR(i,0,adj[v].size()){
		int u = adj[v][i];
		if ( u == Par ) continue;
		dfs( u , lvl + 1 , v );
	}
}

int Solve ( int k ){
	ll res = 0;
	int pick = 0 , head = 0 , id = -1;
	deque <pii> seq = node;
	while ( !seq.empty() && head < seq.size() ){
		if ( id != seq[head].Y ){
			if ( pick < k ){
				res += pick;
				++pick;
			} else{
				res -= (ll) ( seq[head].Y - seq.front().Y );
				seq.pop_front();
				--head;
			}
			id = seq[head].Y;
		} else{
			if ( pick < k )
				++pick;
			else{
				res -= (ll) ( seq[head].Y - seq.front().Y );
				seq.pop_front();
				--head;
			}
		}
		++head;
		if( res <= p ) return 1;
	}
	return 0;
}

int main()
{
	ios::sync_with_stdio(false);

	cin >> n >> k >> p;
	FOR(i,0,n-1){
		int v , u;
		cin >> v >> u;
		--v , u--;
		adj[v].pb(u);
		adj[u].pb(v);
	}
	dfs( 0 , 0 );
	sort( ALL(node) , cmp );
	int st = 1 , en = min( k , n-1 );
	while ( en - st > 1 ){
		int mid = ( st+en ) >> 1;
		if ( Solve( mid ) )
			st = mid;
		else
			en = mid;
	}
	if ( Solve( st ) && st <= en )
		ans = st;
	if ( Solve( en ) )
		ans = en;
	cout << ans << endl;
	return 0;
}


#include <iostream>
#include <fstream>
#include <sstream>
#include <vector>
#include <algorithm>
#include <set>
#include <map>
#include <queue>
#include <deque>
#include <iomanip>
#include <cmath>
#include <cstdio>
#include <cstring>
#include <list>
#include <bitset>
#include <complex>
#include <climits>
#include <cfloat>
#include <limits>

using namespace std;

typedef long long ll;
typedef long double ld;
typedef pair <int,int> pii;
typedef pair <ll,ll> pLL;

#define FOR(i,a,b) for ( int i(a) ; i < int(b) ; i++)
#define ROF(i,a,b) for ( int i(a) ; i >= int(b) ; i--)
#define FOREACH(i,c) for ( __typeof ( (c).begin() ) i = (c).begin() ; i != (c).end() ; i++ )
#define ALL(c) c.begin() , c.end()
#define UNIQUE(c) (c).resize(unique( ALL(c) ) - (c).begin() )
#define pb push_back
#define mp make_pair
#define X first
#define Y second
#define gcd __gcd
#define bcnt(x) ((__builtin_popcount(x)))

const int MAX_N = 100000 + 20;
vector <int> adj[MAX_N];
int lvl[MAX_N];
int n , k , p;
int ans;

void readInput()
{
	cin >> n >> k >> p;
	FOR(i,0,n-1){
		int v , u;
		cin >> v >> u;
		--v , u--;
		adj[v].pb(u);
		adj[u].pb(v);
	}
}

void dfs ( int v , int d , int Par = -1 )
{
	lvl[d]++;
	FOR(i,0,adj[v].size()){
		int u = adj[v][i];
		if ( u == Par ) continue;
		dfs( u , d+1 , v );
	}
}

int Solve ( int res )
{
	deque <pii> seq;
	ll sum = 0;
	int ret = res , pick = 0 , id = 1;
	while( ret > 0 ){
		if ( lvl[id] < ret ){
			sum += pick;
			pick += lvl[id];

			seq.pb( mp( id , lvl[id] ) );

			ret -= lvl[id];
			++id;
		} else{
			sum += pick;
			pick += ret;

			seq.pb( mp(id, ret) );

			ret = 0;
		}
	}
	if ( sum <= p ) return 1;
	for ( int i = id ; i <= n && lvl[i] > 0 ; ++i ){
		if ( i != id ){
			sum += pick;
			seq.pb( mp(i,0) );
		}
		while ( seq.back().Y < min( res , lvl[i] ) ){
			int rem = min( res , lvl[i] ) - seq.back().Y;
			int fr = seq.front().X , frRem = seq.front().Y;
			seq.pop_back();
			seq.pop_front();
			if ( frRem <= rem ){
				sum -= (ll) ( i - fr ) * frRem;
				rem -= frRem;

				seq.pb( mp( i , min( res , lvl[i] ) - rem ) );
			} else{
				sum -= (ll) ( i - fr ) * rem;
				frRem -= rem;

				seq.pb( mp( i , min( res , lvl[i] ) ) );
				seq.push_front( mp( fr , frRem ) );
			}
		}
		if ( sum <= p ) return 1;
	}
	return 0;
}

int main()
{
	ios::sync_with_stdio(false);
	readInput();
	dfs( 0 , 0 );
	int st = 1 , en = min( n-1,k );
	while ( en - st > 1 ){
		int mid = (st + en) >> 1;
		if ( Solve( mid ) )
			st = mid;
		else
			en = mid;
	}
	if ( Solve( st ) && st <= en )
		ans = st;
	if ( Solve( en ) )
		ans = en;
	cout << ans << endl;
	return 0;
}


#include <iostream>
#include <fstream>
#include <sstream>
#include <vector>
#include <algorithm>
#include <set>
#include <map>
#include <queue>
#include <deque>
#include <iomanip>
#include <cmath>
#include <cstdio>
#include <cstring>
#include <list>
#include <bitset>
#include <complex>
#include <climits>
#include <cfloat>
#include <limits>

using namespace std;

typedef long long ll;
typedef long double ld;
typedef pair <int,int> pii;
typedef pair <ll,ll> pLL;

#define FOR(i,a,b) for ( int i(a) ; i < int(b) ; i++)
#define ROF(i,a,b) for ( int i(a) ; i >= int(b) ; i--)
#define FOREACH(i,c) for ( __typeof ( (c).begin() ) i = (c).begin() ; i != (c).end() ; i++ )
#define ALL(c) c.begin() , c.end()
#define UNIQUE(c) (c).resize(unique( ALL(c) ) - (c).begin() )
#define pb push_back
#define mp make_pair
#define X first
#define Y second
#define gcd __gcd
#define bcnt(x) ((__builtin_popcount(x)))

const int MAX_N = 100000 + 20;
vector <int> adj[MAX_N];
int lvl[MAX_N];
int n , k , p;
ll ans;

void dfs ( int v , int d , int Par = -1 ){
	++lvl[d];
	FOR(i,0,adj[v].size()){
		int u = adj[v][i];
		if ( u == Par ) continue;
		dfs( u , d+1 , v );
	}
}

int Solve ( int k ){
	deque <pii> seq;
	ll sum = 0;
	int K = k , fix = 0 , head = 1;
	while ( K > 0 ){
		if ( K > lvl[ head ] ){
			seq.pb( mp( head , lvl[head] ) );
			K -= lvl[head];
			sum += fix;
			fix += lvl[head];
			++head;
		} else{
			seq.pb( mp( head , K ) );
			K = 0;
			fix += lvl[head] - k;
		}

	}
	if ( sum <= p ) return 1;
	for ( int i = head ; i <= n && lvl[i] > 0 ; ++i ){
		seq.pb( mp(i , 0) );
		sum += fix;
		if ( i == head )
			sum -= fix;
		while ( seq.back().Y < lvl[i] ){
			int rem = lvl[i] - seq.back().Y , id = i;
			int be = seq.front().X , rebe = seq.front().Y;
			if ( rebe <= rem ){
				rem -= rebe;
				seq.pop_back();
				seq.pb( mp(id , lvl[i] - rem ) );
				sum -= (ll) ( i - be ) * ( rebe );
				seq.pop_front();
			} else{
				seq.pop_back();
				seq.pb( mp( id , lvl[i] ) );
				sum -= (ll) ( i - be ) * ( rebe - rem );
				seq.pop_front();
				seq.push_front( mp( be , rebe - rem ) );
			}
		}
		if ( sum <= p ) return 1;
	}

	return 0;
}

int main()
{
	ios::sync_with_stdio(false);
	cin >> n >> k >> p;
	FOR(i,0,n-1){
		int v , u ;
		cin >> v >> u;
		--v , u--;
		adj[v].pb(u);
		adj[u].pb(v);
	}
	dfs(0 , 0);
	int st = 1 , en = min(n-1 , k);
	while ( en - st > 1 ){
		int mid = (st + en) >> 1;
		if ( Solve( mid ) )
			st = mid;
		else
			en = mid;
	}
	if ( Solve(st) )
		ans = st;
	if ( Solve(en) )
		ans = en;
	cout << ans << endl;
	return 0;
}


#include <iostream>
#include <algorithm>
#include <vector>
#include <deque>

using namespace std;

const int MAX_N = 100000 + 20;
vector <int> adj[MAX_N];
int lvl[MAX_N];
int n , k , p;
int ans;

void readInput()
{
	cin >> n >> k >> p;
	for ( int i = 0 ; i < n-1 ; i++ ){
		int v , u;
		cin >> v >> u;
		--v , u--;
		adj[v].push_back(u);
		adj[u].push_back(v);
	}

}

void dfs ( int v , int d , int Par = -1 ){
	lvl[d] ++;
	for ( int i = 0 ; i < adj[v].size() ; ++ i ){
		int u = adj[v][i];
		if ( u == Par ) continue;
		dfs ( u , d+1 , v );
	}
}

int Solve ( int res ){
	deque < pair<int,int> > seq;
	long long sum = 0;
	int ret = res , pick = 0 , id = 1;
	while( ret ){
		if ( lvl[id] < ret ){
			ret -= lvl[id];
			seq.push_back( make_pair( id , lvl[id] ) );
			sum += pick;
			pick += lvl[id];
			++id;
		} else{
			seq.push_back( make_pair( id , ret ) );
			sum += pick;
			pick += ret;
			ret = 0;
		}
	}
	if ( sum <= p ) return 1;
	for ( int i = id ; i <= n && lvl[i] > 0 ; ++ i ){
		if ( i != id ){
			sum += res;
			seq.push_back( make_pair( i , 0 ) );
		}
		while ( seq.back().second < min( res , lvl[i] ) ){
			int rem = seq.back().second - min( res , lvl[i] );
			int fr = seq.front().first , frRem = seq.front().second;
			if ( frRem <= rem ){
				sum -= (long long) ( i - fr ) * frRem;
				rem -= frRem;
				seq.pop_back();
				seq.push_back( make_pair( i , min( res , lvl[i] ) - rem ) );
				seq.pop_front();
			} else{
				sum -= (long long) ( i - fr ) * rem;
				frRem -= rem;
				seq.pop_back();
				seq.push_back( make_pair( i , min( res , lvl[i] ) ) );
				seq.pop_front();
				seq.push_front( make_pair( fr , frRem - rem ) );
			}
		}
		if ( sum <= p )
			return 1;
	}
	return 0;

}

int main()
{
	ios::sync_with_stdio(false);
	readInput();
	dfs( 0 , 0 );
	int st = 1 , en = min( n-1 , k );
	while ( en - st > 1 ){
		int mid = (st + en) >> 1;
		if ( Solve( mid ) )
			st = mid;
		else
			en = mid;
	}
	if ( Solve( st ) && st <= en )
		ans = st;
	if ( Solve( en ) )
		ans = en;
	cout << ans << endl;

}


#include <iostream>
#include <fstream>
#include <sstream>
#include <vector>
#include <algorithm>
#include <set>
#include <map>
#include <queue>
#include <deque>
#include <iomanip>
#include <cmath>
#include <cstdio>
#include <cstring>
#include <list>
#include <bitset>
#include <complex>
#include <climits>
#include <cfloat>
#include <limits>

using namespace std;

typedef long long ll;
typedef long double ld;
typedef pair <int,int> pii;
typedef pair <ll,ll> pLL;

#define FOR(i,a,b) for ( int i(a) ; i < int(b) ; i++)
#define ROF(i,a,b) for ( int i(a) ; i >= int(b) ; i--)
#define FOREACH(i,c) for ( __typeof ( (c).begin() ) i = (c).begin() ; i != (c).end() ; i++ )
#define ALL(c) c.begin() , c.end()
#define UNIQUE(c) (c).resize(unique( ALL(c) ) - (c).begin() )
#define pb push_back
#define mp make_pair
#define X first
#define Y second
#define gcd __gcd
#define bcnt(x) ((__builtin_popcount(x)))

const int MAX_N = 100000 + 20;
vector <int> adj[MAX_N];
deque <pii> node;
int n , k , p;
int ans;

int cmp ( const pii &a , const pii &b ){
	return a.Y < b.Y;
}

void dfs ( int v , int lvl , int Par = -1 ){
	node.pb( mp(v,lvl) );
	FOR(i,0,adj[v].size()){
		int u = adj[v][i];
		if ( u == Par ) continue;
		dfs( u , lvl + 1 , v );
	}
}

int Solve ( int k ){
	ll res = 0;
	int pick = 0 , head = 0 , id = -1;
	deque <pii> seq = node;
	while ( !seq.empty() && head < seq.size() ){
		if ( id != seq[head].Y ){
			if ( pick < k ){
				res += pick;
				++pick;
			} else{
				res -= (ll) ( seq[head].Y - seq.front().Y );
				seq.pop_front();
				--head;
			}
			id = seq[head].Y;
		} else{
			if ( pick < k )
				++pick;
			else{
				res -= (ll) ( seq[head].Y - seq.front().Y );
				seq.pop_front();
				--head;
			}
		}
		++head;
		if( res <= (ll) p && pick == k ) return 1;
	}
	return 0;
}

int main()
{
	ios::sync_with_stdio(false);

	cin >> n >> k >> p;
	FOR(i,0,n-1){
		int v , u;
		cin >> v >> u;
		--v , u--;
		adj[v].pb(u);
		adj[u].pb(v);
	}
	dfs( 0 , 0 );
	sort( ALL(node) , cmp );
	int st = 1 , en = min( k , n-1 );
	while ( en - st > 1 ){
		int mid = ( st+en ) >> 1;
		if ( Solve( mid ) )
			st = mid;
		else
			en = mid;
	}
	if ( Solve( st ) && st <= en )
		ans = st;
	if ( Solve( en ) )
		ans = en;
	cout << ans << endl;
	return 0;
}


#include <iostream>
#include <fstream>
#include <sstream>
#include <vector>
#include <algorithm>
#include <set>
#include <map>
#include <queue>
#include <deque>
#include <iomanip>
#include <cmath>
#include <cstdio>
#include <cstring>
#include <list>
#include <bitset>
#include <complex>
#include <climits>
#include <cfloat>
#include <limits>

using namespace std;

typedef long long ll;
typedef long double ld;
typedef pair <int,int> pii;
typedef pair <ll,ll> pLL;

#define FOR(i,a,b) for ( int i(a) ; i < int(b) ; i++)
#define ROF(i,a,b) for ( int i(a) ; i >= int(b) ; i--)
#define FOREACH(i,c) for ( __typeof ( (c).begin() ) i = (c).begin() ; i != (c).end() ; i++ )
#define ALL(c) c.begin() , c.end()
#define UNIQUE(c) (c).resize(unique( ALL(c) ) - (c).begin() )
#define pb push_back
#define mp make_pair
#define X first
#define Y second
#define gcd __gcd
#define bcnt(x) ((__builtin_popcount(x)))

const int MAX_N = 100000 + 20;
vector <int> adj[MAX_N];
int lvl[MAX_N];
int n , k , p;
ll ans;

void dfs ( int v , int d , int Par = -1 ){
	++lvl[d];
	FOR(i,0,adj[v].size()){
		int u = adj[v][i];
		if ( u == Par ) continue;
		dfs( u , d+1 , v );
	}
}

int Solve ( int k ){
	deque <pii> seq;
	ll sum = 0;
	int K = k , fix = 0 , head = 1;
	while ( K > 0 ){
		if ( K >= lvl[ head ] ){
			seq.pb( mp( head , lvl[head] ) );
			K -= lvl[head];
			sum += fix;
			fix += lvl[head];
			++head;
		} else{
			seq.pb( mp( head , lvl[head] - K ) );
			K = 0;
			sum += fix;
			fix += lvl[head] - k;
		}

	}
	if ( sum <= p ) return 1;
	if ( seq.back().Y < lvl[head] && head == seq.back().X ){
		while ( seq.back().Y < lvl[head] ){
			int rem = lvl[head] - seq.back().Y , id = seq.back().X;
			int be = seq.front().X , rebe = seq.front().Y;
			if ( rebe <= rem ){
				rem -= rebe;
				seq.pop_back();
				seq.pb( mp(id , lvl[head] - rem ) );
				sum -= (ll) ( head - be ) * ( rebe );
				seq.pop_front();
			} else{
				seq.pop_back();
				seq.pb( mp( id , lvl[head] ) );
				sum -= (ll) ( head - be ) * ( rebe - rem );
				seq.pop_front();
				seq.push_front( mp( be , rebe - rem ) );
			}
		}
		if ( sum <= p ) return 1;
	}
	for ( int i = head+1 ; i <= n && lvl[i] > 0 ; ++i ){
		seq.pb( mp(i , 0) );
		sum += fix;
		while ( seq.back().Y < lvl[i] ){
			int rem = lvl[i] - seq.back().Y , id = i;
			int be = seq.front().X , rebe = seq.front().Y;
			if ( rebe <= rem ){
				rem -= rebe;
				seq.pop_back();
				seq.pb( mp(id , lvl[i] - rem ) );
				sum -= (ll) ( i - be ) * ( rebe );
				seq.pop_front();
			} else{
				seq.pop_back();
				seq.pb( mp( id , lvl[i] ) );
				sum -= (ll) ( i - be ) * ( rebe - rem );
				seq.pop_front();
				seq.push_front( mp( be , rebe - rem ) );
			}
		}
		if ( sum <= p ) return 1;
	}

	return 0;
}

int main()
{
	ios::sync_with_stdio(false);
	cin >> n >> k >> p;
	FOR(i,0,n-1){
		int v , u ;
		cin >> v >> u;
		--v , u--;
		adj[v].pb(u);
		adj[u].pb(v);
	}
	dfs(0 , 0);
	int st = 1 , en = min(n-1 , k);
	while ( en - st > 1 ){
		int mid = (st + en) >> 1;
		if ( Solve( mid ) )
			st = mid;
		else
			en = mid;
	}
	if ( Solve(st) )
		ans = st;
	if ( Solve(en) )
		ans = en;
	cout << ans << endl;
	return 0;
}


#include <iostream>
#include <fstream>
#include <sstream>
#include <vector>
#include <algorithm>
#include <set>
#include <map>
#include <queue>
#include <deque>
#include <iomanip>
#include <cmath>
#include <cstdio>
#include <cstring>
#include <list>
#include <bitset>
#include <complex>
#include <climits>
#include <cfloat>
#include <limits>

using namespace std;

typedef long long ll;
typedef long double ld;
typedef pair <int,int> pii;
typedef pair <ll,ll> pLL;

#define FOR(i,a,b) for ( int i(a) ; i < int(b) ; i++)
#define ROF(i,a,b) for ( int i(a) ; i >= int(b) ; i--)
#define FOREACH(i,c) for ( __typeof ( (c).begin() ) i = (c).begin() ; i != (c).end() ; i++ )
#define ALL(c) c.begin() , c.end()
#define UNIQUE(c) (c).resize(unique( ALL(c) ) - (c).begin() )
#define pb push_back
#define mp make_pair
#define X first
#define Y second
#define gcd __gcd
#define bcnt(x) ((__builtin_popcount(x)))

const int MAX_N = 100000 + 20;
vector <int> adj[MAX_N];
int lvl[MAX_N];
int n , k , p;
ll ans;

void dfs ( int v , int d , int Par = -1 ){
	++lvl[d];
	FOR(i,0,adj[v].size()){
		int u = adj[v][i];
		if ( u == Par ) continue;
		dfs( u , d+1 , v );
	}
}

int Solve ( int k ){
	deque <pii> seq;
	ll sum = 0;
	int K = k , fix = 0 , head = 1;
	while ( K > 0 ){
		if ( K > lvl[ head ] ){
			seq.pb( mp( head , lvl[head] ) );
			K -= lvl[head];
			sum += fix;
			fix += lvl[head];
			++head;
		} else{
			seq.pb( mp( head , K ) );
			sum += fix;
			fix += K;
			K = 0;
		}

	}
	for ( int i = head ; i <= n && lvl[i] > 0 ; ++i ){
		sum += fix;
		if ( i == head )
			sum -= fix;
		while ( seq.back().Y < lvl[i] ){
			int rem = lvl[i] - seq.back().Y , id = i;
			int be = seq.front().X , rebe = seq.front().Y;
			if ( rebe <= rem ){
				rem -= rebe;
				seq.pop_back();
				seq.pb( mp(id , lvl[i] - rem ) );
				sum -= (ll) ( i - be ) * ( rebe );
				seq.pop_front();
			} else{
				seq.pop_back();
				seq.pb( mp( id , lvl[i] ) );
				sum -= (ll) ( i - be ) * rem;
				seq.pop_front();
				seq.push_front( mp( be , rebe - rem ) );
			}
		}
		if ( sum <= p ) return 1;
	}

	return 0;
}

int main()
{
	ios::sync_with_stdio(false);
	cin >> n >> k >> p;
	FOR(i,0,n-1){
		int v , u ;
		cin >> v >> u;
		--v , u--;
		adj[v].pb(u);
		adj[u].pb(v);
	}
	dfs(0 , 0);
	int st = 1 , en = min(n-1 , k);
	while ( en - st > 1 ){
		int mid = (st + en) >> 1;
		if ( Solve( mid ) )
			st = mid;
		else
			en = mid;
	}
	if ( Solve(st) )
		ans = st;
	if ( Solve(en) )
		ans = en;
	cout << ans << endl;
	return 0;
}


#include <stdio.h>
#include <iostream>
#include <string.h>
#include <string>
#include <math.h>
#include <stdlib.h>
#include <algorithm>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <utility>
#define inf 2000000000
#define ll long long
#define Max 100005

using namespace std;

ll n,mx,p,lev[Max];
vector <ll> v[Max];
ll sum[Max];

void dfs(ll x,ll p,ll l)
{
    if(l) lev[l]++;

    int i,j,k;

    for(i=0;i<v[x].size();i++)
    {
        j=v[x][i];

        if(j==p) continue;

        dfs(j,x,l+1);
    }
}

int main()
{
    //freopen("in.txt","r",stdin);

    ll i,j,k,ret,cost,cnt,nc;
    int i1,i2;

    cin>>n>>k>>p;

    mx=min(n-1,k);

    for(i=1;i<n;i++)
    {
        scanf("%d %d",&i1,&i2);

        v[i1].push_back(i2);
        v[i2].push_back(i1);
    }

    dfs(1,0,0);

    for(sum[1]=lev[1],i=2;lev[i];i++) sum[i]=sum[i-1]+lev[i];

    j=--i;

    for(ret=cost=cnt=0;j;j--)
    {
        while(i)
        {
            nc=sum[j-1]-sum[i-1];

            if(nc+cost<=p)
            {
                cost+=nc;
                cnt+=lev[i];
                i--;
            }

            else break;

        }

        if(i==0)
        {
            ret=max(ret,cnt);
        }

        else
        {
            k=p-cost;
            k=k/(j-i);

            ret-max(ret,cnt+k);
        }

        cnt-=lev[j];
        cost-=(sum[j]-sum[i-1]);

    }

    printf("%d\n",(int)min(ret,mx));

    return 0;
}


#include <stdio.h>
#include <iostream>
#include <string.h>
#include <string>
#include <math.h>
#include <stdlib.h>
#include <algorithm>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <utility>
#define inf 2000000000
#define ll long long
#define Max 100005

using namespace std;

ll n,mx,p,lev[Max];
vector <ll> v[Max];
ll sum[Max];

void dfs(ll x,ll p,ll l)
{
    if(l) lev[l]++;

    int i,j,k;

    for(i=0;i<v[x].size();i++)
    {
        j=v[x][i];

        if(j==p) continue;

        dfs(j,x,l+1);
    }
}

int main()
{
    //freopen("in.txt","r",stdin);

    ll i,j,k,ret,cost,cnt,nc;
    int i1,i2;

    cin>>n>>k>>p;

    mx=min(n-1,k);

    for(i=1;i<n;i++)
    {
        scanf("%d %d",&i1,&i2);

        v[i1].push_back(i2);
        v[i2].push_back(i1);
    }

    dfs(1,0,0);

    for(sum[1]=lev[1],i=2;lev[i];i++) sum[i]=sum[i-1]+lev[i];

    j=--i;

    for(ret=cost=cnt=0;j;j--)
    {
        while(i)
        {
            nc=(j-i)*lev[i];

            if(nc+cost<=p)
            {
                cost+=nc;
                cnt+=lev[i];
                i--;
            }

            else break;

        }

        if(i==0)
        {
            ret=max(ret,cnt);
        }

        else
        {
            k=p-cost;
            k=k/(j-i);

            ret-max(ret,cnt+k);
        }

        cnt-=lev[j];
        cost-=(sum[j]-sum[i-1]);

    }

    printf("%d\n",(int)min(ret,mx));

    return 0;
}


#include <stdio.h>
#include <iostream>
#include <string.h>
#include <string>
#include <math.h>
#include <stdlib.h>
#include <algorithm>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <utility>
#define inf 2000000000
#define ll long long
#define Max 100005

using namespace std;

ll n,mx,p,lev[Max];
vector <ll> v[Max];
ll sum[Max];

void dfs(ll x,ll par,ll l)
{
    if(l) lev[l]++;

    int i,j,k;

    for(i=0;i<v[x].size();i++)
    {
        j=v[x][i];

        if(j==par) continue;

        dfs(j,x,l+1);
    }
}

int main()
{
    //freopen("in.txt","r",stdin);

    ll i,j,k,ret,cost,cnt,nc;
    int i1,i2;

    cin>>n>>k>>p;

    mx=min(n-1,k);

    for(i=1;i<n;i++)
    {
        scanf("%d %d",&i1,&i2);

        v[i1].push_back(i2);
        v[i2].push_back(i1);
    }

    dfs(1,0,0);

    for(sum[1]=lev[1],i=2;lev[i];i++) sum[i]=sum[i-1]+lev[i];

    j=--i;

    //cout<<j<<" "<<i<<endl;

    for(ret=cost=cnt=0;j;j--)
    {
        while(i)
        {
            nc=(j-i)*lev[i];

            if(nc+cost<=p)
            {
                cost+=nc;
                cnt+=lev[i];
                i--;
            }

            else break;

        }

        if(i==0)
        {
            ret=max(ret,cnt);
        }

        else
        {
            k=p-cost;
            k=k/(j-i);

            ret=max(ret,cnt+k);
        }

        cnt-=lev[j];
        cost-=(sum[j-1]-sum[i]);

    }

    printf("%d\n",(int)min(ret,mx));

    return 0;
}


#include <stdio.h>
#include <iostream>
#include <string.h>
#include <string>
#include <math.h>
#include <stdlib.h>
#include <algorithm>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <utility>
#define inf 2000000000
#define ll long long
#define Max 100005

using namespace std;

ll n,mx,p,lev[Max];
vector <ll> v[Max];
ll sum[Max];

void dfs(ll x,ll p,ll l)
{
    if(l) lev[l]++;

    int i,j,k;

    for(i=0;i<v[x].size();i++)
    {
        j=v[x][i];

        if(j==p) continue;

        dfs(j,x,l+1);
    }
}

int main()
{
    //freopen("in.txt","r",stdin);

    ll i,j,k,ret,cost,cnt,nc;
    int i1,i2;

    cin>>n>>k>>p;

    mx=min(n-1,k);

    for(i=1;i<n;i++)
    {
        scanf("%d %d",&i1,&i2);

        v[i1].push_back(i2);
        v[i2].push_back(i1);
    }

    dfs(1,0,0);

    for(sum[1]=lev[1],i=2;lev[i];i++) sum[i]=sum[i-1]+lev[i];

    j=--i;

    for(ret=cost=cnt=0;j;j--)
    {
        while(i)
        {
            nc=(j-i)*lev[i];

            if(nc+cost<=p)
            {
                cost+=nc;
                cnt+=lev[i];
                i--;
            }

            else break;

        }

        if(i==0)
        {
            ret=max(ret,cnt);
        }

        else
        {
            k=p-cost;
            k=k/(j-i);

            ret=max(ret,cnt+k);
        }

        cnt-=lev[j];
        cost-=(sum[j]-sum[i]);

    }

    printf("%d\n",(int)min(ret,mx));

    return 0;
}


#include <stdio.h>
#include <iostream>
#include <string.h>
#include <string>
#include <math.h>
#include <stdlib.h>
#include <algorithm>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <utility>
#define inf 2000000000
#define ll long long
#define Max 100005

using namespace std;

ll n,mx,p,lev[Max];
vector <ll> v[Max];
ll sum[Max];

void dfs(ll x,ll p,ll l)
{
    if(l) lev[l]++;

    int i,j,k;

    for(i=0;i<v[x].size();i++)
    {
        j=v[x][i];

        if(j==p) continue;

        dfs(j,x,l+1);
    }
}

int main()
{
    //freopen("in.txt","r",stdin);

    ll i,j,k,ret,cost,cnt,nc;
    int i1,i2;

    cin>>n>>k>>p;

    mx=min(n-1,k);

    for(i=1;i<n;i++)
    {
        scanf("%d %d",&i1,&i2);

        v[i1].push_back(i2);
        v[i2].push_back(i1);
    }

    dfs(1,0,0);

    for(sum[1]=lev[1],i=2;lev[i];i++) sum[i]=sum[i-1]+lev[i];

    j=--i;

    for(ret=cost=cnt=0;j;j--)
    {
        while(i)
        {
            nc=(j-i)*lev[i];

            if(nc+cost<=p)
            {
                cost+=nc;
                cnt+=lev[i];
                i--;
            }

            else break;

        }

        if(i==0)
        {
            ret=max(ret,cnt);
        }

        else
        {
            k=p-cost;
            k=k/(j-i);

            ret=max(ret,cnt+k);
        }

        cnt-=lev[j];
        cost-=(sum[j]-sum[i-1]);

    }

    printf("%d\n",(int)min(ret,mx));

    return 0;
}


#include <iostream>
#include <cstdio>
#include <vector>
#include <algorithm>
using namespace std;

typedef long long int llint;

const int MAXN=100010;

int n,k,p,najveca,rj;
int num[MAXN];

vector<int>graf[MAXN];

void rek(int cvor, int roditelj, int dubina)
{
    num[dubina]++;
    najveca=max(najveca,dubina);
    for(int i=0;i<graf[cvor].size();i++)
        if(graf[cvor][i]!=roditelj)
            rek(graf[cvor][i],cvor,dubina+1);
}

int main()
{
    scanf("%d %d %d",&n,&k,&p);
    for(int i=0;i<n-1;i++)
    {
        int a,b;
        scanf("%d %d",&a,&b);
        graf[a].push_back(b);
        graf[b].push_back(a);
    }
    rek(1,-1,0);
    int broj_njih=0;
    int g=najveca+1;
    llint val=0;
    for(int d=najveca;d>=1;d--)
    {
        val-=(llint)(d+1)*num[d+1];
        broj_njih-=num[d+1];
        for(;g>=2;g--)
        {
            if((llint)(broj_njih+num[g-1])*d-(val+(llint)(g-1)*num[g-1])>p)
            {
                int sad=(p-(llint)broj_njih*d+val)/(d-g+1);
                rj=max(rj,broj_njih+sad);
                break;
            }
            else
            {
                val+=(llint)(g-1)*num[g-1];
                broj_njih+=num[g-1];
            }
        }
        if(g==1)rj=max(rj,broj_njih);
    }
    rj=min(rj,k);
    printf("%d\n",rj);
    return 0;
}


#include <iostream>
#include <cstdio>
#include <vector>
#include <algorithm>
using namespace std;

typedef long long int llint;

const int MAXN=100010;

int n,k,p,najveca,rj;
int num[MAXN];

vector<int>graf[MAXN];

void rek(int cvor, int roditelj, int dubina)
{
    num[dubina]++;
    najveca=max(najveca,dubina);
    for(int i=0;i<graf[cvor].size();i++)
        if(graf[cvor][i]!=roditelj)
            rek(graf[cvor][i],cvor,dubina+1);
}

int main()
{
    scanf("%d %d %d",&n,&k,&p);
    for(int i=0;i<n-1;i++)
    {
        int a,b;
        scanf("%d %d",&a,&b);
        graf[a].push_back(b);
        graf[b].push_back(a);
    }
    rek(1,-1,0);
    int broj_njih=0;
    int g=najveca+1;
    llint val=0;
    for(int d=najveca;d>=1;d--)
    {
        val-=(llint)(d+1)*num[d+1];
        broj_njih-=num[d+1];
        for(;g>=2;g--)
        {
            if((llint)(broj_njih+num[g-1])*d-(val+(llint)(g-1)*num[g-1])>p)
            {
                int sad=(p-(llint)broj_njih*d+val)/(d-g+1);
                rj=max(rj,sad);
                break;
            }
            else
            {
                val+=(llint)(g-1)*num[g-1];
                broj_njih+=num[g-1];
            }
        }
        if(g==1)rj=max(rj,broj_njih);
    }
    rj=min(rj,k);
    printf("%d\n",rj);
    return 0;
}


#include <iostream>
#include <cstdio>
#include <vector>
#include <algorithm>
using namespace std;

typedef long long int llint;

const int MAXN=100010;

int n,k,p,najveca,rj;
int num[MAXN];

vector<int>graf[MAXN];

void rek(int cvor, int roditelj, int dubina)
{
    num[dubina]++;
    najveca=max(najveca,dubina);
    for(int i=0;i<graf[cvor].size();i++)
        if(graf[cvor][i]!=roditelj)
            rek(graf[cvor][i],cvor,dubina+1);
}

int main()
{
    scanf("%d %d %d",&n,&k,&p);
    for(int i=0;i<n-1;i++)
    {
        int a,b;
        scanf("%d %d",&a,&b);
        graf[a].push_back(b);
        graf[b].push_back(a);
    }
    rek(1,-1,0);
    int broj_njih=0;
    int g=najveca+1;
    llint val=0;
    for(int d=najveca;d>=1;d--)
    {
        val-=(llint)(d+1)*num[d+1];
        broj_njih-=num[d+1];
        for(;g>=2;g--)
        {
            if(val+(llint)(g-1)*num[g-1]-(llint)(broj_njih+num[g-1])*d>p)
            {
                rj=max(rj,(int)(((p-val+(llint)broj_njih*d)/(g+d-1))));
                break;
            }
            else
            {
                val+=(llint)(g-1)*num[g-1];
                broj_njih+=num[g-1];
            }
        }
        if(g==1)rj=max(rj,broj_njih);
    }
    rj=min(rj,k);
    printf("%d\n",rj);
    return 0;
}


/*
I heard somebody fixed today
There was no last goodbyes to say
His will to live ran out
I heard somebody turned to dust

Looking back at what he left
A list of plans and photographs
Songs that never will be sung
These are the things he won't get done
The things he won't get done

I've seen the man use the needle
Seen the needle use the man
I've seen them crawl from the cradle
To the gutter on their hands
The fight a war but it's fatal
It's so hard to understand
I've seen the man use the needle
Seen the needle use the man

Just one shot to say goodbye
One last taste to mourn and cry
Cry, cry
Scores and shoots, the lights go dim
Just one shot to do him in

He hangs his head and wonders why
Why the monkey only lies
Lies, lies
But pay the pauper, he did choose
He hung his head inside the noose
He hung his head inside the noose

I've seen the man use the needle
Seen the needle use that man
I've seen them crawl from the cradle
To the coffin on their hands
They fight a war but it's fatal
It's so hard to understand
I've seen the man use the needle
Seen the needle in his hand
Cryptic writing on the wall
The beginning of the end
I've seen myself use the needle
Seen the needle in my hand

I've seen the man use the needle
Seen the needle use that man
I've seen them crawl from the cradle
To the coffin on their hands
They fight a war but it's fatal
It's so hard to understand
I've seen myself use the needle
Seen the needle in my hand

In my hand
In my hand
In my hand
*/

//#pragma comment(linker, "/STACK:16777216")
#include <fstream>
#include <iostream>
#include <string>
#include <complex>
#include <math.h>
#include <set>
#include <vector>
#include <map>
#include <queue>
#include <stdio.h>
#include <stack>
#include <algorithm>
#include <list>
#include <ctime>
#include <memory.h>

#define y0 sdkfaslhagaklsldk
#define y1 aasdfasdfasdf
#define yn askfhwqriuperikldjk
#define j1 assdgsdgasghsf
#define tm sdfjahlfasfh
#define lr asgasgash

#define  INF 100000000
#define eps 1e-11
//#define M_PI 3.141592653589793
//#define mx 1000000000000ll
#define bs 1000000007
#define bsize 256

using namespace std;

long m,k,p,a,b;
vector<long> g[200000];
long used[200000];
long dep[200000];
long level[200000];
long l,r,mid;

void dfs(long v)
{
 used[v]=1;
 level[dep[v]]++;
 for (int i=0;i<g[v].size();i++)
 {
  long q=g[v][i];
  if (used[q])continue;
  dep[q]=dep[v]+1;
  dfs(q);
 }
}

long long ttl,lev,qlev,tcost;
long long d,upl;

void pop(long val)
{
 ttl-=(level[qlev]);
 tcost-=ttl;
 if (ttl<=0||tcost<0)ttl=tcost=0;
}

void add(long val)
{
 if (ttl==val)return;
 if (d<level[upl]){long span=min(level[upl]-d,val-ttl);ttl+=span;tcost+=(qlev-upl)*span;d+=span;return;}
 d=0;
 upl--;
// if (upl<=1){ttl=1e9;return;}
}

bool solve(long val)
{
 if (val==0)return true;
 if (val==1)return (k>0);

long long bcost=2e9;
 upl=m;
 d=0;
 ttl=0;
 tcost=0;
 for (int i=m+1;i;--i)
 {
  qlev=i;
  if (upl>qlev){upl=qlev;d=0;}
  while (ttl<val&&upl>1){add(val);}
  if (tcost<bcost&&ttl==val)bcost=tcost;
//  cout<<i<<"   "<<tcost<<" "<<val<<endl;
  pop(val);
//  cout<<i<<"   "<<" "<<upl<<" "<<d<<" "<<tcost<<" "<<val<<endl;

 }
// cout<<val<<"  "<<bcost<<endl;
 if (ttl<=p)return true;
 return false;
}

int main(){
//freopen("melman.in","r",stdin);
//freopen("melman.out","w",stdout);
//freopen("C:/input.txt","r",stdin);
//freopen("C:/output.txt","w",stdout);
ios_base::sync_with_stdio(0);
cin.tie(0);

cin>>m>>k>>p;
for (int i=1;i<m;i++)
{
 cin>>a>>b;
 g[a].push_back(b);
 g[b].push_back(a);
}

dep[1]=1;

dfs(1);

/*for (int i=0;i<=10;i++)
cout<<level[i]<<endl;
*/

l=0;
r=m-1;
if (r>k)r=k;

while (l<r)
{
 long mid=l+r+1;
 mid/=2;
 if (solve(mid))l=mid;
 else r=mid-1;
}
cout<<l<<endl;

cin.get();cin.get();
return 0;}


/*
I heard somebody fixed today
There was no last goodbyes to say
His will to live ran out
I heard somebody turned to dust

Looking back at what he left
A list of plans and photographs
Songs that never will be sung
These are the things he won't get done
The things he won't get done

I've seen the man use the needle
Seen the needle use the man
I've seen them crawl from the cradle
To the gutter on their hands
The fight a war but it's fatal
It's so hard to understand
I've seen the man use the needle
Seen the needle use the man

Just one shot to say goodbye
One last taste to mourn and cry
Cry, cry
Scores and shoots, the lights go dim
Just one shot to do him in

He hangs his head and wonders why
Why the monkey only lies
Lies, lies
But pay the pauper, he did choose
He hung his head inside the noose
He hung his head inside the noose

I've seen the man use the needle
Seen the needle use that man
I've seen them crawl from the cradle
To the coffin on their hands
They fight a war but it's fatal
It's so hard to understand
I've seen the man use the needle
Seen the needle in his hand
Cryptic writing on the wall
The beginning of the end
I've seen myself use the needle
Seen the needle in my hand

I've seen the man use the needle
Seen the needle use that man
I've seen them crawl from the cradle
To the coffin on their hands
They fight a war but it's fatal
It's so hard to understand
I've seen myself use the needle
Seen the needle in my hand

In my hand
In my hand
In my hand
*/

//#pragma comment(linker, "/STACK:16777216")
#include <fstream>
#include <iostream>
#include <string>
#include <complex>
#include <math.h>
#include <set>
#include <vector>
#include <map>
#include <queue>
#include <stdio.h>
#include <stack>
#include <algorithm>
#include <list>
#include <ctime>
#include <memory.h>

#define y0 sdkfaslhagaklsldk
#define y1 aasdfasdfasdf
#define yn askfhwqriuperikldjk
#define j1 assdgsdgasghsf
#define tm sdfjahlfasfh
#define lr asgasgash

#define  INF 100000000
#define eps 1e-11
//#define M_PI 3.141592653589793
//#define mx 1000000000000ll
#define bs 1000000007
#define bsize 256

using namespace std;

long m,k,p,a,b;
vector<long> g[200000];
long used[200000];
long dep[200000];
long level[200000];
long l,r,mid;

void dfs(long v)
{
 used[v]=1;
 level[dep[v]]++;
 for (int i=0;i<g[v].size();i++)
 {
  long q=g[v][i];
  if (used[q])continue;
  dep[q]=dep[v]+1;
  dfs(q);
 }
}

long long ttl,lev,qlev,tcost;
long long d,upl;

void pop(long val)
{
 ttl-=(level[qlev]);
 tcost-=ttl;
 if (ttl<=0||tcost<0)ttl=tcost=0;
}

void add(long val)
{
 if (ttl==val)return;
 if (d<level[upl]){long span=min(level[upl]-d,val-ttl);ttl+=span;tcost+=(qlev-upl)*span;d+=span;return;}
 d=0;
 upl--;
// if (upl<=1){ttl=1e9;return;}
}

bool solve(long val)
{
 if (val==0)return true;
 if (val==1)return (k>0);

long long bcost=2e9;
 upl=m;
 d=0;
 ttl=0;
 tcost=0;
 for (int i=m+1;i;--i)
 {
  qlev=i;
  if (upl>qlev){upl=qlev;d=0;}
  while (ttl<val&&upl>1){add(val);}
  if (tcost<bcost&&ttl==val)bcost=tcost;
//  cout<<i<<"   "<<tcost<<" "<<val<<endl;
  pop(val);
//  cout<<i<<"   "<<" "<<upl<<" "<<d<<" "<<tcost<<" "<<val<<endl;

 }
// cout<<val<<"  "<<bcost<<endl;
 if (bcost<=p)return true;
 return false;
}

int main(){
//freopen("melman.in","r",stdin);
//freopen("melman.out","w",stdout);
//freopen("C:/input.txt","r",stdin);
//freopen("C:/output.txt","w",stdout);
ios_base::sync_with_stdio(0);
cin.tie(0);

cin>>m>>k>>p;
for (int i=1;i<m;i++)
{
 cin>>a>>b;
 g[a].push_back(b);
 g[b].push_back(a);
}

dep[1]=1;

dfs(1);

/*for (int i=0;i<=10;i++)
cout<<level[i]<<endl;
*/

l=0;
r=m-1;
if (r>k)r=k;

while (l<r)
{
 long mid=l+r+1;
 mid/=2;
 if (solve(mid))l=mid;
 else r=mid-1;
}
cout<<l<<endl;

cin.get();cin.get();
return 0;}


/*
I heard somebody fixed today
There was no last goodbyes to say
His will to live ran out
I heard somebody turned to dust

Looking back at what he left
A list of plans and photographs
Songs that never will be sung
These are the things he won't get done
The things he won't get done

I've seen the man use the needle
Seen the needle use the man
I've seen them crawl from the cradle
To the gutter on their hands
The fight a war but it's fatal
It's so hard to understand
I've seen the man use the needle
Seen the needle use the man

Just one shot to say goodbye
One last taste to mourn and cry
Cry, cry
Scores and shoots, the lights go dim
Just one shot to do him in

He hangs his head and wonders why
Why the monkey only lies
Lies, lies
But pay the pauper, he did choose
He hung his head inside the noose
He hung his head inside the noose

I've seen the man use the needle
Seen the needle use that man
I've seen them crawl from the cradle
To the coffin on their hands
They fight a war but it's fatal
It's so hard to understand
I've seen the man use the needle
Seen the needle in his hand
Cryptic writing on the wall
The beginning of the end
I've seen myself use the needle
Seen the needle in my hand

I've seen the man use the needle
Seen the needle use that man
I've seen them crawl from the cradle
To the coffin on their hands
They fight a war but it's fatal
It's so hard to understand
I've seen myself use the needle
Seen the needle in my hand

In my hand
In my hand
In my hand
*/

//#pragma comment(linker, "/STACK:16777216")
#include <fstream>
#include <iostream>
#include <string>
#include <complex>
#include <math.h>
#include <set>
#include <vector>
#include <map>
#include <queue>
#include <stdio.h>
#include <stack>
#include <algorithm>
#include <list>
#include <ctime>
#include <memory.h>

#define y0 sdkfaslhagaklsldk
#define y1 aasdfasdfasdf
#define yn askfhwqriuperikldjk
#define j1 assdgsdgasghsf
#define tm sdfjahlfasfh
#define lr asgasgash

#define  INF 100000000
#define eps 1e-11
//#define M_PI 3.141592653589793
//#define mx 1000000000000ll
#define bs 1000000007
#define bsize 256

using namespace std;

long m,k,p,a,b;
vector<long> g[200000];
long used[200000];
long dep[200000];
long level[200000];
long l,r,mid;

void dfs(long v)
{
 used[v]=1;
 level[dep[v]]++;
 for (int i=0;i<g[v].size();i++)
 {
  long q=g[v][i];
  if (used[q])continue;
  dep[q]=dep[v]+1;
  dfs(q);
 }
}

long long ttl,lev,qlev,tcost;
long long d,upl;

void pop(long val)
{
 ttl-=(val-level[qlev]);
 tcost-=ttl;
 if (ttl<0||tcost<0)ttl=tcost=0;
}

void add(long val)
{
 if (ttl==val)return;
 if (d<level[upl]){long span=min(level[upl]-d,val-ttl);ttl+=span;tcost+=(qlev-upl)*span;d+=span;return;}
 d=0;
 upl--;
 if (upl<=1){ttl=1e9;return;}
}

bool solve(long val)
{
 if (val==0)return true;
 if (val==1)return (k>0);

long long bcost=2e9;
 upl=m;
 d=0;
 ttl=0;
 tcost=0;
 for (int i=m+1;i;--i)
 {
  qlev=i;
  while (ttl<val){add(val);}
  if (tcost<bcost&&upl>1)bcost=tcost;
//  cout<<i<<"   "<<tcost<<" "<<val<<endl;
  pop(val);
//  cout<<i<<"   "<<" "<<upl<<" "<<d<<" "<<tcost<<" "<<val<<endl;

 }
// cout<<val<<"  "<<bcost<<endl;
 if (ttl<=p)return true;
 return false;
}

int main(){
//freopen("melman.in","r",stdin);
//freopen("melman.out","w",stdout);
//freopen("C:/input.txt","r",stdin);
//freopen("C:/output.txt","w",stdout);
ios_base::sync_with_stdio(0);
cin.tie(0);

cin>>m>>k>>p;
for (int i=1;i<m;i++)
{
 cin>>a>>b;
 g[a].push_back(b);
 g[b].push_back(a);
}

dep[1]=1;

dfs(1);

/*for (int i=0;i<=10;i++)
cout<<level[i]<<endl;
*/

l=0;
r=m-1;
if (r>k)r=k;

while (l<r)
{
 long mid=l+r+1;
 mid/=2;
 if (solve(mid))l=mid;
 else r=mid-1;
}
cout<<l<<endl;

cin.get();cin.get();
return 0;}


/*
I heard somebody fixed today
There was no last goodbyes to say
His will to live ran out
I heard somebody turned to dust

Looking back at what he left
A list of plans and photographs
Songs that never will be sung
These are the things he won't get done
The things he won't get done

I've seen the man use the needle
Seen the needle use the man
I've seen them crawl from the cradle
To the gutter on their hands
The fight a war but it's fatal
It's so hard to understand
I've seen the man use the needle
Seen the needle use the man

Just one shot to say goodbye
One last taste to mourn and cry
Cry, cry
Scores and shoots, the lights go dim
Just one shot to do him in

He hangs his head and wonders why
Why the monkey only lies
Lies, lies
But pay the pauper, he did choose
He hung his head inside the noose
He hung his head inside the noose

I've seen the man use the needle
Seen the needle use that man
I've seen them crawl from the cradle
To the coffin on their hands
They fight a war but it's fatal
It's so hard to understand
I've seen the man use the needle
Seen the needle in his hand
Cryptic writing on the wall
The beginning of the end
I've seen myself use the needle
Seen the needle in my hand

I've seen the man use the needle
Seen the needle use that man
I've seen them crawl from the cradle
To the coffin on their hands
They fight a war but it's fatal
It's so hard to understand
I've seen myself use the needle
Seen the needle in my hand

In my hand
In my hand
In my hand
*/

//#pragma comment(linker, "/STACK:16777216")
#include <fstream>
#include <iostream>
#include <string>
#include <complex>
#include <math.h>
#include <set>
#include <vector>
#include <map>
#include <queue>
#include <stdio.h>
#include <stack>
#include <algorithm>
#include <list>
#include <ctime>
#include <memory.h>

#define y0 sdkfaslhagaklsldk
#define y1 aasdfasdfasdf
#define yn askfhwqriuperikldjk
#define j1 assdgsdgasghsf
#define tm sdfjahlfasfh
#define lr asgasgash

#define  INF 100000000
#define eps 1e-11
//#define M_PI 3.141592653589793
//#define mx 1000000000000ll
#define bs 1000000007
#define bsize 256

using namespace std;

long m,k,p,a,b;
vector<long> g[200000];
long used[200000];
long dep[200000];
long level[200000];
long l,r,mid;

void dfs(long v)
{
 used[v]=1;
 level[dep[v]]++;
 for (int i=0;i<g[v].size();i++)
 {
  long q=g[v][i];
  if (used[q])continue;
  dep[q]=dep[v]+1;
  dfs(q);
 }
}

long long ttl,lev,qlev,tcost;
long long d,upl;

void pop(long val)
{
 ttl-=(level[qlev]);
 tcost-=ttl;
 if (ttl<=0||tcost<0)ttl=tcost=0;
}

void add(long val)
{
 if (ttl==val)return;
 if (d<level[upl]){long span=min(level[upl]-d,val-ttl);ttl+=span;tcost+=(qlev-upl)*span;d+=span;return;}
 d=0;
 upl--;
// if (upl<=1){ttl=1e9;return;}
}

bool solve(long val)
{
 if (val==0)return true;
 if (val==1)return (k>0);

long long bcost=2e9;
 upl=m;
 d=0;
 ttl=0;
 tcost=0;
 for (int i=m+1;i;--i)
 {
  qlev=i;
  while (ttl<val&&upl>1){add(val);}
  if (tcost<bcost&&ttl==val)bcost=tcost;
//  cout<<i<<"   "<<tcost<<" "<<val<<endl;
  pop(val);
//  cout<<i<<"   "<<" "<<upl<<" "<<d<<" "<<tcost<<" "<<val<<endl;

 }
// cout<<val<<"  "<<bcost<<endl;
 if (ttl<=p)return true;
 return false;
}

int main(){
//freopen("melman.in","r",stdin);
//freopen("melman.out","w",stdout);
//freopen("C:/input.txt","r",stdin);
//freopen("C:/output.txt","w",stdout);
ios_base::sync_with_stdio(0);
cin.tie(0);

cin>>m>>k>>p;
for (int i=1;i<m;i++)
{
 cin>>a>>b;
 g[a].push_back(b);
 g[b].push_back(a);
}

dep[1]=1;

dfs(1);

/*for (int i=0;i<=10;i++)
cout<<level[i]<<endl;
*/

l=0;
r=m-1;
if (r>k)r=k;

while (l<r)
{
 long mid=l+r+1;
 mid/=2;
 if (solve(mid))l=mid;
 else r=mid-1;
}
cout<<l<<endl;

cin.get();cin.get();
return 0;}


/*
I heard somebody fixed today
There was no last goodbyes to say
His will to live ran out
I heard somebody turned to dust

Looking back at what he left
A list of plans and photographs
Songs that never will be sung
These are the things he won't get done
The things he won't get done

I've seen the man use the needle
Seen the needle use the man
I've seen them crawl from the cradle
To the gutter on their hands
The fight a war but it's fatal
It's so hard to understand
I've seen the man use the needle
Seen the needle use the man

Just one shot to say goodbye
One last taste to mourn and cry
Cry, cry
Scores and shoots, the lights go dim
Just one shot to do him in

He hangs his head and wonders why
Why the monkey only lies
Lies, lies
But pay the pauper, he did choose
He hung his head inside the noose
He hung his head inside the noose

I've seen the man use the needle
Seen the needle use that man
I've seen them crawl from the cradle
To the coffin on their hands
They fight a war but it's fatal
It's so hard to understand
I've seen the man use the needle
Seen the needle in his hand
Cryptic writing on the wall
The beginning of the end
I've seen myself use the needle
Seen the needle in my hand

I've seen the man use the needle
Seen the needle use that man
I've seen them crawl from the cradle
To the coffin on their hands
They fight a war but it's fatal
It's so hard to understand
I've seen myself use the needle
Seen the needle in my hand

In my hand
In my hand
In my hand
*/

//#pragma comment(linker, "/STACK:16777216")
#include <fstream>
#include <iostream>
#include <string>
#include <complex>
#include <math.h>
#include <set>
#include <vector>
#include <map>
#include <queue>
#include <stdio.h>
#include <stack>
#include <algorithm>
#include <list>
#include <ctime>
#include <memory.h>

#define y0 sdkfaslhagaklsldk
#define y1 aasdfasdfasdf
#define yn askfhwqriuperikldjk
#define j1 assdgsdgasghsf
#define tm sdfjahlfasfh
#define lr asgasgash

#define  INF 100000000
#define eps 1e-11
//#define M_PI 3.141592653589793
//#define mx 1000000000000ll
#define bs 1000000007
#define bsize 256

using namespace std;

long m,k,p,a,b;
vector<long> g[200000];
long used[200000];
long dep[200000];
long level[200000];
long l,r,mid;

void dfs(long v)
{
 used[v]=1;
 level[dep[v]]++;
 for (int i=0;i<g[v].size();i++)
 {
  long q=g[v][i];
  if (used[q])continue;
  dep[q]=dep[v]+1;
  dfs(q);
 }
}

long long ttl,lev,qlev,tcost;
long long d,upl;

void pop(long val)
{
 ttl-=(val-level[qlev]);
 tcost-=ttl;
 if (ttl<0||tcost<0)ttl=tcost=0;
}

void add(long val)
{
 if (ttl==val)return;
 if (d<level[upl]){long span=min(level[upl]-d,val-ttl);ttl+=span;tcost+=(qlev-upl)*span;d+=span;return;}
 d=0;
 upl--;
// if (upl<=1){ttl=1e9;return;}
}

bool solve(long val)
{
 if (val==0)return true;
 if (val==1)return (k>0);

long long bcost=2e9;
 upl=m;
 d=0;
 ttl=0;
 tcost=0;
 for (int i=m+1;i;--i)
 {
  qlev=i;
  while (ttl<val&&upl>1){add(val);}
  if (tcost<bcost&&ttl==val)bcost=tcost;
//  cout<<i<<"   "<<tcost<<" "<<val<<endl;
  pop(val);
//  cout<<i<<"   "<<" "<<upl<<" "<<d<<" "<<tcost<<" "<<val<<endl;

 }
// cout<<val<<"  "<<bcost<<endl;
 if (ttl<=p)return true;
 return false;
}

int main(){
//freopen("melman.in","r",stdin);
//freopen("melman.out","w",stdout);
//freopen("C:/input.txt","r",stdin);
//freopen("C:/output.txt","w",stdout);
ios_base::sync_with_stdio(0);
cin.tie(0);

cin>>m>>k>>p;
for (int i=1;i<m;i++)
{
 cin>>a>>b;
 g[a].push_back(b);
 g[b].push_back(a);
}

dep[1]=1;

dfs(1);

/*for (int i=0;i<=10;i++)
cout<<level[i]<<endl;
*/

l=0;
r=m-1;
if (r>k)r=k;

while (l<r)
{
 long mid=l+r+1;
 mid/=2;
 if (solve(mid))l=mid;
 else r=mid-1;
}
cout<<l<<endl;

cin.get();cin.get();
return 0;}


#include <algorithm>
#include <cstring>
#include <cstdlib>
#include <cstdio>
#include <vector>
#include <ctime>
#define fi first
#define se second
#define PA pair<int,int>
#define VI vector<int>
#define VP vector<PA >
#define mk(x,y) make_pair(x,y)
#define N 100010
#define int64 long long
#define For(i,x,y) for (i=x;i<=y;i++)
using namespace std;
int i,j,k,n,m,P,s,an;
int ge[N];
VI a[N];
void dfs(int x,int y,int dep) {
	int i;
	if (dep>s) s=dep;
	ge[dep]++;
	for (i=0;i<a[x].size();i++) {
		int A=a[x][i];
		if (A==y) continue;
		dfs(A,x,dep+1);
	}
}
int main() {
	scanf("%d%d%d",&n,&m,&P);
	For(i,1,n-1) {
		int x,y;
		scanf("%d%d",&x,&y);
		a[x].push_back(y);
		a[y].push_back(x);
	}
	{
		s=0;
		dfs(1,0,0);
		For(i,1,s) {
			int64 cost=0;
			int sum=0;
			for (j=i,k=0;j;j--,k++) {
				if (cost+1ll*k*ge[j]<=P) {
					cost+=1ll*k*ge[j];
					sum+=ge[j];
					an=max(an,sum);
				} else {
					int A=(P-cost)/k;
					an=max(an,sum+A);
					break;
				}
			}
		}
	}
	printf("%d\n",min(an,m));
	return 0;
}


#include <algorithm>
#include <cstring>
#include <cstdlib>
#include <cstdio>
#include <vector>
#include <ctime>
#define fi first
#define se second
#define PA pair<int,int>
#define VI vector<int>
#define VP vector<PA >
#define mk(x,y) make_pair(x,y)
#define N 100010
#define int64 long long
#define For(i,x,y) for (i=x;i<=y;i++)
using namespace std;
int i,j,k,n,m,P,s,an;
int ge[N],b[N];
VI a[N];
void dfs(int x,int y,int dep) {
	int i;
	if (dep>s) s=dep;
	ge[dep]++;
	for (i=0;i<a[x].size();i++) {
		int A=a[x][i];
		if (A==y) continue;
		dfs(A,x,dep+1);
	}
}
int main() {
	scanf("%d%d%d",&n,&m,&P);
	For(i,1,n-1) {
		int x,y;
		scanf("%d%d",&x,&y);
		a[x].push_back(y);
		a[y].push_back(x);
	}
	{
		dfs(1,0,0);
		For(i,1,s) b[i]=b[i-1]+ge[i];
		int64 cost,sum;
		cost=sum=0;
		j=1; ge[0]=0;
		For(i,1,s) {
			cost+=b[i-1]-b[j-1];
			sum+=ge[i];
			for (;cost>P;j++) cost-=1ll*ge[j]*(i-j),sum-=ge[j];
			an=max(0ll+an,sum+min(0ll+ge[j-1],(P-cost)/(i-(j-1))));
		}
	}
	printf("%d\n",min(an,m));
	return 0;
}


#include <algorithm>
#include <cstring>
#include <cstdlib>
#include <cstdio>
#include <vector>
#include <ctime>
#define fi first
#define se second
#define PA pair<int,int>
#define VI vector<int>
#define VP vector<PA >
#define mk(x,y) make_pair(x,y)
#define N 100010
#define int64 long long
#define For(i,x,y) for (i=x;i<=y;i++)
using namespace std;
int i,j,k,n,m,P,s,an;
int ge[N];
VI a[N];
void dfs(int x,int y,int dep) {
	int i;
	if (dep>s) s=dep;
	ge[dep]++;
	for (i=0;i<a[x].size();i++) {
		int A=a[x][i];
		if (A==y) continue;
		dfs(A,x,dep+1);
	}
}
int main() {
	scanf("%d%d%d",&n,&m,&P);
	For(i,1,n-1) {
		int x,y;
		scanf("%d%d",&x,&y);
		a[x].push_back(y);
		a[y].push_back(x);
	}
	{
		s=0;
		dfs(1,0,0);
		For(i,1,s) {
			int cost=0;
			int sum=0;
			for (j=i,k=0;j;j--,k++) {
				if (cost+1ll*k*ge[j]<=P) {
					cost+=1ll*k*ge[j];
					sum+=ge[j];
					an=max(an,sum);
				} else {
					int A=(P-cost)/k;
					an=max(an,sum+A);
					break;
				}
			}
		}
	}
	printf("%d\n",min(an,m));
	return 0;
}


#include<cstdio>
#include<iostream>
#include<cmath>
#include<cstring>
#include<cstdlib>
#include<algorithm>
#include<map>
using namespace std;
int i,j,k,l,n,m,s,sum,K,C,X,tot,an,nn,V;
const int N=410000;
int e[N],next[N],go[N];
int g[N],fa[N],h[N];
void add(int x,int y)
{
    tot++;e[tot]=y;next[tot]=go[x];go[x]=tot;
}
int main()
{
    scanf("%d%d%d",&n,&K,&V);
    K=min(K,n);
    for (int i=1;i<n;i++)
    {
        int x,y;
        scanf("%d%d",&x,&y);
        add(x,y);
        add(y,x);
    }
    int l=0;
    int r=1;
    g[1]=1;
    h[1]=1;
    fa[1]=-1;
    while (l<r)
    {
        int x=g[++l];
        for (int p=go[x];p;p=next[p])
        if (!fa[e[p]])
        {
            fa[e[p]]=x;
            h[e[p]]=h[x]+1;
            g[++r]=e[p];
        }
    }
    fa[1]=0;
    int s=0;
    l=2;
    //int hh=2;
    for (int i=2;i<=n;i++)
    {
        if (h[i]!=h[i-1]) s+=(i-1-l+1);
        while ((s>V)&&(l<=i))
        {
            s-=(h[i]-h[l]);
            l++;
        }
        an=max(an,i-l+1);
    }
    an=min(an,K);
    printf("%d\n",an);
    //system("pause");
    return 0;
}


#include<cstdio>
#include<iostream>
#include<cmath>
#include<cstring>
#include<cstdlib>
#include<algorithm>
#include<map>
using namespace std;
int i,j,k,l,n,m,s,sum,K,C,X,tot,an,nn,V;
const int N=410000;
int e[N],next[N],go[N];
int g[N],fa[N],h[N];
void add(int x,int y)
{
    tot++;e[tot]=y;next[tot]=go[x];go[x]=tot;
}
int main()
{
    scanf("%d%d%d",&n,&K,&V);
    K=min(K,n);
    for (int i=1;i<n;i++)
    {
        int x,y;
        scanf("%d%d",&x,&y);
        add(x,y);
        add(y,x);
    }
    int l=0;
    int r=1;
    g[1]=1;
    h[1]=1;
    fa[1]=-1;
    while (l<r)
    {
        int x=g[++l];
        for (int p=go[x];p;p=next[p])
        if (!fa[e[p]])
        {
            fa[e[p]]=x;
            h[e[p]]=h[x]+1;
            g[++r]=e[p];
        }
    }
    fa[1]=0;
    for (int i=2;i<=n;i++)
    {
        int s=0;
        for (int j=i-1;(j>1)&&(j>=i-K+1);j--)
        {
            s+=(h[i]-h[j]);
            if (s>V) break;
            an=max(an,i-j+1);
        }
    }
    printf("%d\n",an);
    //system("pause");
    return 0;
}


#include<cstdio>
#include<iostream>
#include<cmath>
#include<cstring>
#include<cstdlib>
#include<algorithm>
#include<map>
using namespace std;
int i,j,k,l,n,m,s,sum,K,C,X,tot,an,nn,V;
const int N=410000;
int e[N],next[N],go[N];
int g[N],fa[N],h[N];
void add(int x,int y)
{
    tot++;e[tot]=y;next[tot]=go[x];go[x]=tot;
}
int main()
{
    scanf("%d%d%d",&n,&K,&V);
    K=min(K,n);
    for (int i=1;i<n;i++)
    {
        int x,y;
        scanf("%d%d",&x,&y);
        add(x,y);
        add(y,x);
    }
    int l=0;
    int r=1;
    g[1]=1;
    h[1]=1;
    fa[1]=-1;
    while (l<r)
    {
        int x=g[++l];
        for (int p=go[x];p;p=next[p])
        if (!fa[e[p]])
        {
            fa[e[p]]=x;
            h[e[p]]=h[x]+1;
            g[++r]=e[p];
        }
    }
    fa[1]=0;
    int s=0;
    l=2;
    //int hh=2;
    for (int i=2;i<=n;i++)
    {
        if (h[g[i]]!=h[g[i-1]]) s+=(i-1-l+1);
        while ((s>V)&&(l<=i))
        {
            s-=(h[g[i]]-h[g[l]]);
            l++;
        }
        an=max(an,i-l+1);
    }
    an=min(an,K);
    printf("%d\n",an);
    //system("pause");
    return 0;
}


#include <bits/stdc++.h>
using namespace std;

int n, k, p, depth[100100];
vector <int> a[100100];

void visit(int x, int par)
{
	for (int i = 0; i < int(a[x].size()); i++)
	{
		int y = a[x][i];
		if (y == par) continue;
		depth[y] = depth[x] + 1;
		visit(y, x);
	}
}

int main()
{
	ios::sync_with_stdio(0);

	int x, y;
	cin >> n >> k >> p;
	for (int i = 1; i < n; i++)
	{
		cin >> x >> y;
		a[x].push_back(y);
		a[y].push_back(x);
	}

	visit(1, 0);
	sort(depth + 2, depth + n + 1, greater<int>());

	int ans = 1;
	long long need = 0;
	for (int i = 2, j = 2; i <= n; i++)
	{
		while (i <= n && need + depth[j] - depth[i] <= p) need += depth[j] - depth[i++];
		ans = max(ans, min(k, i - j));
		need -= (depth[j] - depth[j + 1]) * (i - 1 - j);
		j++;
	}

	cout << ans << endl;
}


#include <bits/stdc++.h>
using namespace std;

int n, k, p, depth[100100];
vector <int> a[100100];

void visit(int x, int par)
{
	for (int i = 0; i < int(a[x].size()); i++)
	{
		int y = a[x][i];
		if (y == par) continue;
		depth[y] = depth[x] + 1;
		visit(y, x);
	}
}

int main()
{
	ios::sync_with_stdio(0);

	int x, y;
	cin >> n >> k >> p;
	for (int i = 1; i < n; i++)
	{
		cin >> x >> y;
		a[x].push_back(y);
		a[y].push_back(x);
	}

	visit(1, 0);
	sort(depth + 2, depth + n + 1, greater<int>());

	int ans = 1;
	long long need = 0;
	for (int i = 2, j = 2; i <= n; i++)
	{
		while (i <= n && need + depth[j] - depth[i] <= p) i++, need += depth[j] - depth[i];
		ans = max(ans, min(k, i - j));
		need -= (depth[j] - depth[j + 1]) * (i - j);
		j++;
	}

	cout << ans << endl;
}


#include <bits/stdc++.h>
using namespace std;

int n, k, coins, depth[100100], p[100100][22], children[100100][22];
long long sum[100100][22];
vector <int> a[100100], nodesAtDepth[100100];

void visit(int x, int par)
{
	nodesAtDepth[depth[x]].push_back(x);
	p[x][0] = par;
	children[x][0] = a[x].size() - (par ? 1 : 0);
	sum[x][0] = children[x][0] + 2;

	for (int i = 0; i < int(a[x].size()); i++)
	{
		int y = a[x][i];
		if (y == par) continue;
		depth[y] = depth[x] + 1;
		visit(y, x);
	}
}

int getKthAncestor(int x, int k)
{
	for (int i = 20; i >= 0; i--)
		if (1 << i <= k)
		{
			k -= 1 << i;
			x = p[x][i];
		}
	return x;
}

int solve(int x)
{
	int lg = 0;
	while (p[x][lg + 1]) lg++;

	int coinsLeft = coins, y = x, res = children[x][0];
	long long pass = 0;

	for (int i = lg; i >= 0; i--)
		if (sum[p[y][i]][i] + children[p[y][i]][i] * pass <= coinsLeft)
		{
			y = p[y][i];
			coinsLeft -= sum[y][i] + children[y][i] * pass;
			res += children[y][i];
			pass |= 1 << i;
		}

	return res;
}

int main()
{
	ios::sync_with_stdio(0);
	//freopen("d.in", "r", stdin);

	int x, y;
	cin >> n >> k >> coins;
	for (int i = 1; i < n; i++)
	{
		cin >> x >> y;
		a[x].push_back(y);
		a[y].push_back(x);
	}

	visit(1, 0);
	for (int i = 0; 1 << i <= n; i++)
		for (int x = 1; x <= n; x++)
			p[x][i + 1] = p[p[x][i]][i];

	for (int i = 0; 1 << i <= n; i++)
		for (int x = 1; x <= n; x++)
		{
			children[x][i + 1] += children[x][i];
			sum[x][i + 1] += sum[x][i] + children[x][0] * (1LL << i);
			if (p[x][i])
			{
				children[p[x][i]][i + 1] += children[x][i];
				sum[p[x][i]][i + 1] += sum[x][i];
			}
		}

	int ans = 1;
	for (int x = 1; x <= n; x++) ans = max(ans, solve(x));
	cout << ans << endl;
}


#include <bits/stdc++.h>
using namespace std;

int n, k, p, depth[100100];
long long sumDepth[100100];
vector <int> a[100100];

void visit(int x, int par)
{
	for (int i = 0; i < int(a[x].size()); i++)
	{
		int y = a[x][i];
		if (y == par) continue;
		depth[y] = depth[x] + 1;
		visit(y, x);
	}
}

int main()
{
	ios::sync_with_stdio(0);

	int x, y;
	cin >> n >> k >> p;
	for (int i = 1; i < n; i++)
	{
		cin >> x >> y;
		a[x].push_back(y);
		a[y].push_back(x);
	}

	visit(1, 0);
	sort(depth + 2, depth + n + 1, greater<int>());
	for (int i = 2; i <= n; i++) sumDepth[i] = sumDepth[i - 1] + depth[i];

	int ans = 1;
	for (int i = 2; i <= n; i++)
	{
		int low = i + 1, high = n, res = i;
		while (low <= high)
		{
			int mid = (low + high) / 2;
			if (1LL * depth[i] * (mid - i + 1) - (sumDepth[mid] - sumDepth[i - 1]) <= p)
			{
				low = mid + 1;
				res = mid;
			}
			else high = mid - 1;
		}
		ans = max(ans, min(k, res - i + 1));
	}

	cout << ans << endl;
}


#pragma  comment(linker, "/STACK:36777216")
#include <map>
#include <set>
#include <cmath>
#include <queue>
#include <cstdio>
#include <string>
#include <vector>
#include <iomanip>
#include <cassert>
#include <cstdlib>
#include <cstring>
#include <iostream>
#include <algorithm>
#define  lc(x) (x<<1)
#define  rc(x) (lc(x)+1)
#define  PI    (acos(-1))
#define  EPS   1e-8
#define  MAXN  1111111
#define  MAXM  888888
#define  LL    long long
#define  ULL   unsigned long long
#define  INF   0x7fffffff
#define  pb    push_back
#define  mp    make_pair
#define  MOD   1000000007
#define  lowbit(x) (x&(-x))

using namespace std;

struct edge{
    int v, next;
}e[MAXN << 1];

int first[MAXN], ecnt, num[MAXN], sum[MAXN], mx;

void addedge(int u, int v){
    e[++ ecnt].v = v, e[ecnt].next = first[u], first[u] = ecnt;
}

void dfs(int u, int dd, int pre){
    num[dd] ++;
    mx = max(mx, dd);
    for(int i = first[u]; i != -1; i = e[i].next){
        int v = e[i].v;
        if(v == pre) continue;
        dfs(v, dd + 1, u);
    }
}

int calc(int i, int j){
    if(i > j) return 0;
    if(i == 0) return sum[j];
    return sum[j] - sum[i - 1];
}

int n, coins, water, x, y, ans;

int main(){
    //freopen("in.txt", "r", stdin);
    cin >> n >> water >> coins;
    ecnt = -1;
    memset(first, -1, sizeof(first));
    for(int i = 1; i < n; i ++){
        scanf("%d%d", &x, &y);
        addedge(x, y), addedge(y, x);
    }
    dfs(1, 0, 0);
    // the depth of root is 0
    sum[0] = num[0] = 0;
    for(int i = 1; i <= mx; i ++){
        sum[i] = sum[i - 1] + num[i];
        if(num[i] >= water) ans = max(ans, water);
    }
    /*for(int i = 0; i <= mx; i ++)
        cout << i << ' ' << num[i] << ' ' << sum[i] << endl;
    cout << ans << endl;*/
    int l = mx, r = mx, totc = 0, totw = num[mx];
    while(1){
        if(l > r) l = r, totc = 0, totw = num[l];
        while(l == r && totw > water && l >= 1) r --, l --, totw = num[l];
        if(l == -1) break;
        while(l >= 1 && totc + calc(l - 1, r - 1) <= coins && totw + num[l - 1] <= water)
            totc += calc(l - 1, r - 1), totw += num[l - 1], l --;
        //cout << l << ' ' << r << ' ' << totw << ' ' << totc << endl;
        if(l == 0){
            ans = max(ans, calc(l, r));
            break;
        }
        int leftw = water - totw;
        int leftc = (coins - totc) / (r - l + 1);
        ans = max(ans, calc(l, r) + min(leftw, leftc));

        totc -= calc(l, r - 1);
        totw -= num[r];
        r --;
    }
    cout << ans << endl;
}


#pragma  comment(linker, "/STACK:36777216")
#include <map>
#include <set>
#include <cmath>
#include <queue>
#include <cstdio>
#include <string>
#include <vector>
#include <iomanip>
#include <cassert>
#include <cstdlib>
#include <cstring>
#include <iostream>
#include <algorithm>
#define  lc(x) (x<<1)
#define  rc(x) (lc(x)+1)
#define  PI    (acos(-1))
#define  EPS   1e-8
#define  MAXN  111111
#define  MAXM  888888
#define  LL    long long
#define  ULL   unsigned long long
#define  INF   0x7fffffff
#define  pb    push_back
#define  mp    make_pair
#define  MOD   1000000007
#define  lowbit(x) (x&(-x))

using namespace std;

struct edge{
    int v, next;
}e[MAXN << 1];

int first[MAXN], ecnt, num[MAXN], sum[MAXN], mx, dep[MAXN];

void addedge(int u, int v){
    e[++ ecnt].v = v, e[ecnt].next = first[u], first[u] = ecnt;
}

void bfs(){
    queue <int> Q;
    Q.push(1);
    memset(dep, -1, sizeof(dep));
    dep[1] = 0;
    while(!Q.empty()){
        int u = Q.front(); Q.pop();
        num[dep[u]] ++;
        mx = max(mx, dep[u]);
        for(int i = first[u]; i != -1; i = e[i].next){
            int v = e[i].v;
            if(dep[v] != -1) continue;
            dep[v] = dep[u] + 1;
            Q.push(v);
        }
    }
}

int calc(int i, int j){
    if(i > j) return 0;
    if(i == 0) return sum[j];
    return sum[j] - sum[i - 1];
}

int n, coins, water, x, y, ans;

int main(){
    //freopen("in.txt", "r", stdin);
    cin >> n >> water >> coins;
    ecnt = -1;
    memset(first, -1, sizeof(first));
    for(int i = 1; i < n; i ++){
        scanf("%d%d", &x, &y);
        addedge(x, y), addedge(y, x);
    }
    bfs();
    // the depth of root is 0
    sum[0] = num[0] = 0;
    for(int i = 1; i <= mx; i ++){
        sum[i] = sum[i - 1] + num[i];
        if(num[i] >= water) ans = water;
    }
    /*for(int i = 1; i <= mx; i ++)
        cout << i << ' ' << num[i] << ' ' << sum[i] << endl;*/
    int l = mx, r = mx, totc = 0, totw = num[mx];
    while(1){
        if(l > r) l = r, totc = 0, totw = num[l];
        while(l == r && totw > water && l >= 1) r --, l --, totw = num[l];
        if(l == -1) break;
        //cout << l << ' ' << r << ' ' << totw << ' ' << totc << endl;
        while(l >= 1 && totc + (LL) num[l - 1] * (r - l + 1) <= coins && totw + num[l - 1] <= water)
            totc += (LL) num[l - 1] * (r - l + 1), totw += num[l - 1], l --;
        if(l == 0){
            ans = max(ans, calc(l, r));
            break;
        }
        int leftw = water - totw;
        int leftc = (coins - totc) / (r - l + 1);
        ans = max(ans, calc(l, r) + min(leftw, leftc));
        //cout << l << ' ' << r << ' ' << totw << ' ' << totc << ' ' << leftw << ' ' << leftc << endl;

        totc -= calc(l, r - 1);
        totw -= num[r];
        r --;
    }
    cout << ans << endl;
}


#pragma  comment(linker, "/STACK:36777216")
#include <map>
#include <set>
#include <cmath>
#include <queue>
#include <cstdio>
#include <string>
#include <vector>
#include <iomanip>
#include <cassert>
#include <cstdlib>
#include <cstring>
#include <iostream>
#include <algorithm>
#define  lc(x) (x<<1)
#define  rc(x) (lc(x)+1)
#define  PI    (acos(-1))
#define  EPS   1e-8
#define  MAXN  1111111
#define  MAXM  888888
#define  LL    long long
#define  ULL   unsigned long long
#define  INF   0x7fffffff
#define  pb    push_back
#define  mp    make_pair
#define  MOD   1000000007
#define  lowbit(x) (x&(-x))

using namespace std;

struct edge{
    int v, next;
}e[MAXN << 1];

int first[MAXN], ecnt, num[MAXN], sum[MAXN], mx;

void addedge(int u, int v){
    e[++ ecnt].v = v, e[ecnt].next = first[u], first[u] = ecnt;
}

void dfs(int u, int dd, int pre){
    num[dd] ++;
    mx = max(mx, dd);
    for(int i = first[u]; i != -1; i = e[i].next){
        int v = e[i].v;
        if(v == pre) continue;
        dfs(v, dd + 1, u);
    }
}

int calc(int i, int j){
    if(i > j) return 0;
    if(i == 0) return sum[j];
    return sum[j] - sum[i - 1];
}

int n, coins, water, x, y, ans;

int main(){
    //freopen("in.txt", "r", stdin);
    cin >> n >> water >> coins;
    ecnt = -1;
    memset(first, -1, sizeof(first));
    for(int i = 1; i < n; i ++){
        scanf("%d%d", &x, &y);
        addedge(x, y), addedge(y, x);
    }
    dfs(1, 0, 0);
    // the depth of root is 0
    sum[0] = num[0] = 0;
    for(int i = 1; i <= mx; i ++){
        sum[i] = sum[i - 1] + num[i];
        if(num[i] >= water) ans = water;
    }
    /*for(int i = 1; i <= mx; i ++)
        cout << i << ' ' << num[i] << ' ' << sum[i] << endl;*/
    int l = mx, r = mx, totc = 0, totw = num[mx];
    while(1){
        if(l > r) l = r, totc = 0, totw = num[l];
        while(l == r && totw > water && l >= 1) r --, l --, totw = num[l];
        if(l == -1) break;
        //cout << l << ' ' << r << ' ' << totw << ' ' << totc << endl;
        while(l >= 1 && totc + num[l - 1] * (r - l + 1) <= coins && totw + num[l - 1] <= water)
            totc += num[l - 1] * (r - l + 1), totw += num[l - 1], l --;
        if(l == 0){
            ans = max(ans, calc(l, r));
            break;
        }
        int leftw = water - totw;
        int leftc = (coins - totc) / (r - l + 1);
        ans = max(ans, calc(l, r) + min(leftw, leftc));
        //cout << l << ' ' << r << ' ' << totw << ' ' << totc << ' ' << leftw << ' ' << leftc << endl;

        totc -= calc(l, r - 1);
        totw -= num[r];
        r --;
    }
    cout << ans << endl;
}


#pragma  comment(linker, "/STACK:36777216")
#include <map>
#include <set>
#include <cmath>
#include <queue>
#include <cstdio>
#include <string>
#include <vector>
#include <iomanip>
#include <cassert>
#include <cstdlib>
#include <cstring>
#include <iostream>
#include <algorithm>
#define  lc(x) (x<<1)
#define  rc(x) (lc(x)+1)
#define  PI    (acos(-1))
#define  EPS   1e-8
#define  MAXN  111111
#define  MAXM  888888
#define  LL    long long
#define  ULL   unsigned long long
#define  INF   0x7fffffff
#define  pb    push_back
#define  mp    make_pair
#define  MOD   1000000007
#define  lowbit(x) (x&(-x))

using namespace std;

struct edge{
    int v, next;
}e[MAXN << 1];

int first[MAXN], ecnt, num[MAXN], sum[MAXN], mx, dep[MAXN];

void addedge(int u, int v){
    e[++ ecnt].v = v, e[ecnt].next = first[u], first[u] = ecnt;
}

void bfs(){
    queue <int> Q;
    Q.push(1);
    memset(dep, -1, sizeof(dep));
    dep[1] = 0;
    while(!Q.empty()){
        int u = Q.front(); Q.pop();
        num[dep[u]] ++;
        mx = max(mx, dep[u]);
        for(int i = first[u]; i != -1; i = e[i].next){
            int v = e[i].v;
            if(dep[v] != -1) continue;
            dep[v] = dep[u] + 1;
            Q.push(v);
        }
    }
}

int calc(int i, int j){
    if(i > j) return 0;
    if(i == 0) return sum[j];
    return sum[j] - sum[i - 1];
}

int n, coins, water, x, y, ans;

int main(){
    //freopen("in.txt", "r", stdin);
    cin >> n >> water >> coins;
    ecnt = -1;
    memset(first, -1, sizeof(first));
    for(int i = 1; i < n; i ++){
        scanf("%d%d", &x, &y);
        addedge(x, y), addedge(y, x);
    }
    bfs();
    // the depth of root is 0
    sum[0] = num[0] = 0;
    for(int i = 1; i <= mx; i ++){
        sum[i] = sum[i - 1] + num[i];
        if(num[i] >= water) ans = water;
    }
    /*for(int i = 1; i <= mx; i ++)
        cout << i << ' ' << num[i] << ' ' << sum[i] << endl;*/
    int l = mx, r = mx, totc = 0, totw = num[mx];
    while(1){
        if(l > r) l = r, totc = 0, totw = num[l];
        while(l == r && totw > water && l >= 1) r --, l --, totw = num[l];
        if(l == -1) break;
        //cout << l << ' ' << r << ' ' << totw << ' ' << totc << endl;
        while(l >= 1 && totc + num[l - 1] * (r - l + 1) <= coins && totw + num[l - 1] <= water)
            totc += num[l - 1] * (r - l + 1), totw += num[l - 1], l --;
        if(l == 0){
            ans = max(ans, calc(l, r));
            break;
        }
        int leftw = water - totw;
        int leftc = (coins - totc) / (r - l + 1);
        ans = max(ans, calc(l, r) + min(leftw, leftc));
        //cout << l << ' ' << r << ' ' << totw << ' ' << totc << ' ' << leftw << ' ' << leftc << endl;

        totc -= calc(l, r - 1);
        totw -= num[r];
        r --;
    }
    cout << ans << endl;
}


#include <iostream>
#include <cstdio>
#include <cmath>
#include <vector>
#include <map>
#include <set>
#include <string>
#include <cstring>
#include <algorithm>
#include <iomanip>
#include <queue>
#include <cstdlib>
#include <ctime>
#include <cassert>
#include <stack>
#include <bitset>
#include <sstream>
#include <fstream>

typedef unsigned long long ull;
#define mp make_pair
#define pb push_back

const long double eps = 1e-9;
const double pi = acos(-1.0);
const long long inf = 1e18;

using namespace std;

int m, k, p, depth[ 100100 ];
vector< int > graph[ 100100 ];

void dfs( int v, int prev )
{
	for ( int i = 0; i < graph[v].size(); i++ )
	{
		int next = graph[v][i];
		if ( next == prev ) continue;
		depth[ next ] = depth[ v ] + 1;
		dfs( next, v );
	}
}

int fun( int num )
{
	int result = 0, value = depth[ num + 1 ];
	for ( int i = 2; i <= num + 1; i++ )
	{
		result += value - depth[i];
		if ( result > p ) return result;
	}
	return result;
}

int main (int argc, const char * argv[])
{
	scanf("%d%d%d", &m, &k, &p);
	k = min( k, m - 1 );
	for ( int i = 1; i < m; i++ )
	{
		int a, b; scanf("%d%d", &a, &b);
		graph[a].push_back( b );
		graph[b].push_back( a );
	}
	dfs( 1, -1 );
	sort( depth + 1, depth + m + 1 );
	int l = 1, r = k, result = 0;
	while ( l <= r )
	{
		int x = (l + r) / 2;
		if ( fun( x ) <= p )
		{
			result = max( result, x );
			l = x + 1;
		} else r = x - 1;
	}
	printf("%d\n", result);
    return 0;
}


#include <iostream>
#include <cstdio>
#include <cmath>
#include <vector>
#include <map>
#include <set>
#include <string>
#include <cstring>
#include <algorithm>
#include <iomanip>
#include <queue>
#include <cstdlib>
#include <ctime>
#include <cassert>
#include <stack>
#include <bitset>
#include <sstream>
#include <fstream>

typedef unsigned long long ull;
#define mp make_pair
#define pb push_back

const long double eps = 1e-9;
const double pi = acos(-1.0);
const long long inf = 1e18;

using namespace std;

int m, k, p, depth[ 100100 ];
long long sum[ 100100 ];
vector< int > graph[ 100100 ];

void dfs( int v, int prev )
{
	for ( int i = 0; i < graph[v].size(); i++ )
	{
		int next = graph[v][i];
		if ( next == prev ) continue;
		depth[ next ] = depth[ v ] + 1;
		dfs( next, v );
	}
}

long long fun( int num )
{
	long long result = inf;
	for ( int i = 2 ;; i++ )
	{
		if ( i + num - 1 > m ) break;
		long long current = 1ll * depth[ i + num - 1 ] * num - ( sum[ i + num - 1 ] - sum[ i - 1 ] );// - 2ll * ( depth[i] - 1 ) * num;
		result = min( result, current );
	}
	return result;
}

int main (int argc, const char * argv[])
{
	scanf("%d%d%d", &m, &k, &p);
	k = min( k, m - 1 );
	for ( int i = 1; i < m; i++ )
	{
		int a, b; scanf("%d%d", &a, &b);
		graph[a].push_back( b );
		graph[b].push_back( a );
	}
	dfs( 1, -1 );
	sort( depth + 1, depth + m + 1 );
	for ( int i = 1; i <= m; i++ ) sum[i] = sum[i - 1] + depth[i];
	int l = 1, r = k, result = 0;
	while ( l <= r )
	{
		int x = (l + r) / 2;
		if ( fun( x ) <= p )
		{
			result = max( result, x );
			l = x + 1;
		} else r = x - 1;
	}
	printf("%d\n", result);
    return 0;
}


#include <iostream>
#include <cstdio>
#include <cmath>
#include <vector>
#include <map>
#include <set>
#include <string>
#include <cstring>
#include <algorithm>
#include <iomanip>
#include <queue>
#include <cstdlib>
#include <ctime>
#include <cassert>
#include <stack>
#include <bitset>
#include <sstream>
#include <fstream>

typedef unsigned long long ull;
#define mp make_pair
#define pb push_back

const long double eps = 1e-9;
const double pi = acos(-1.0);
const long long inf = 1e18;

using namespace std;

int m, k, p, depth[ 100100 ];
long long sum[ 100100 ];
vector< int > graph[ 100100 ];

void dfs( int v, int prev )
{
	for ( int i = 0; i < graph[v].size(); i++ )
	{
		int next = graph[v][i];
		if ( next == prev ) continue;
		depth[ next ] = depth[ v ] + 1;
		dfs( next, v );
	}
}

long long fun( int num )
{
	long long result = inf;
	for ( int i = 2 ;; i++ )
	{
		if ( i + num - 1 > m ) break;
		long long current = 1ll * depth[ i + num - 1 ] * num - ( sum[ i + num - 1 ] - sum[ i - 1 ] ) - 1ll * ( depth[i] - 1 ) * num;
		result = min( result, current );
	}
	return result;
}

int main (int argc, const char * argv[])
{
	scanf("%d%d%d", &m, &k, &p);
	k = min( k, m - 1 );
	for ( int i = 1; i < m; i++ )
	{
		int a, b; scanf("%d%d", &a, &b);
		graph[a].push_back( b );
		graph[b].push_back( a );
	}
	dfs( 1, -1 );
	sort( depth + 1, depth + m + 1 );
	for ( int i = 1; i <= m; i++ ) sum[i] = sum[i - 1] + depth[i];
	int l = 1, r = k, result = 0;
	while ( l <= r )
	{
		int x = (l + r) / 2;
		if ( fun( x ) <= p )
		{
			result = max( result, x );
			l = x + 1;
		} else r = x - 1;
	}
	printf("%d\n", result);
    return 0;
}


#include <iostream>
#include <cstdio>
#include <cmath>
#include <vector>
#include <map>
#include <set>
#include <string>
#include <cstring>
#include <algorithm>
#include <iomanip>
#include <queue>
#include <cstdlib>
#include <ctime>
#include <cassert>
#include <stack>
#include <bitset>
#include <sstream>
#include <fstream>

typedef unsigned long long ull;
#define mp make_pair
#define pb push_back

const long double eps = 1e-9;
const double pi = acos(-1.0);
const long long inf = 1e18;

using namespace std;

int m, k, p, depth[ 100100 ];
vector< int > graph[ 100100 ];

void dfs( int v, int prev )
{
	for ( int i = 0; i < graph[v].size(); i++ )
	{
		int next = graph[v][i];
		if ( next == prev ) continue;
		depth[ next ] = depth[ v ] + 1;
		dfs( next, v );
	}
}

int fun( int num )
{
	int result = 0, value = depth[ num + 1 ];
	for ( int i = 2; i <= num + 1; i++ )
	{
		result += value - depth[i];
		if ( result > 1000000000 ) return result;
	}
	return result;
}

int main (int argc, const char * argv[])
{
	scanf("%d%d%d", &m, &k, &p);
	k = min( k, m - 1 );
	for ( int i = 1; i < m; i++ )
	{
		int a, b; scanf("%d%d", &a, &b);
		graph[a].push_back( b );
		graph[b].push_back( a );
	}
	dfs( 1, -1 );
	sort( depth + 1, depth + m + 1 );
	int l = 1, r = k, result = 0;
	while ( l <= r )
	{
		int x = (l + r) / 2;
		if ( fun( x ) <= p )
		{
			result = max( result, x );
			l = x + 1;
		} else r = x - 1;
	}
	printf("%d\n", result);
    return 0;
}


#include <iostream>
#include <cstdio>
#include <vector>
using namespace std;

#define ll                      long long

#define inc(i,a,b)              for(int i=a;i<=b;++i)
#define dec(i,a,b)              for(int i=a;i>=b;--i)

#define pb                      push_back
#define sz(arr)                 ((int)(arr.size()))

const int maxM = 1e5+5;

int m, k, p, e;
vector<int> adj[maxM];
int lev[maxM], cap[maxM], cur[maxM];

void dfs(int u) {
    cap[lev[u]]++;
    e = max(e,lev[u]+1);

    inc(i,0,sz(adj[u])-1) {
        int v = adj[u][i];
        if(lev[v]==0) {
            lev[v] = lev[u]+1;
            dfs(v);
        }
    }
}

int main() {
    ios::sync_with_stdio(false);
    cin >> m >> k >> p;

    inc(i,1,m-1) {
        int a, b;
        cin >> a >> b;

        adj[a].pb(b);
        adj[b].pb(a);
    }

    lev[1] = 1;
    dfs(1);

    int l = 0, u = k+1;
    while(u-l>1) {
        int d = (l+u)/2;

        inc(i,1,e-1) cur[i] = 0;
        cur[e] = d;

        int best = 1e9+7;
        int cost = 0;

        int s = e, f = e;
        while(1) {
            int buffer = cur[f];
            int next = s;
            if(next==f) next--;

            cost -= (d-buffer);
            f = f-1;

            while(next>=1) {
                if(buffer<=cap[next]) {
                    cur[next] = buffer;
                    buffer -= buffer;
                    cost += buffer*(f-next);
                    break;
                }
                else {
                    cur[next] = cap[next];
                    buffer -= cap[next];
                    cost += cap[next]*(f-next);
                    next--;
                }
            }

            s = next;

            if(s<=1) {
                break;
            }

            best = min(cost,best);
        }
//         cout << d << " " << best << "\n";

        if(best <= p) {
            l = d;
        }
        else {
            u = d;
        }
    }

    cout << l;
}


#include <iostream>
#include <cstdio>
#include <vector>
using namespace std;

#define ll                      long long

#define inc(i,a,b)              for(int i=a;i<=b;++i)
#define dec(i,a,b)              for(int i=a;i>=b;--i)

#define pb                      push_back
#define sz(arr)                 ((int)(arr.size()))

const int maxM = 1e5+5;

int m, k, p, e;
vector<int> adj[maxM];
int lev[maxM], cap[maxM], cur[maxM];

void dfs(int u) {
    cap[lev[u]]++;
    e = max(e,lev[u]+1);

    inc(i,0,sz(adj[u])-1) {
        int v = adj[u][i];
        if(lev[v]==0) {
            lev[v] = lev[u]+1;
            dfs(v);
        }
    }
}

int main() {
    ios::sync_with_stdio(false);
    cin >> m >> k >> p;

    inc(i,1,m-1) {
        int a, b;
        cin >> a >> b;

        adj[a].pb(b);
        adj[b].pb(a);
    }

    lev[1] = 1;
    dfs(1);

    int l = 0, u = k+1;
    while(u-l>1) {
        int d = (l+u)/2;

        inc(i,1,e-1) cur[i] = 0;
        cur[e] = d;

        int best = 1e9+7;
        int cost = 0;

        int s = e, f = e;
        while(1) {
            int buffer = cur[f];
            int next = s;
            if(next==f) next--;

            cost -= (d-buffer);
            f = f-1;

            while(next>1) {
                if(buffer<=cap[next]-cur[next]) {
                    cur[next] += buffer;
                    cost += buffer*(f-next);
                    buffer -= buffer;
                    break;
                }
                else {
                    cost += (cap[next]-cur[next])*(f-next);
                    buffer -= (cap[next]-cur[next]);
                    cur[next] = cap[next];
                    next--;
                }
            }

            s = next;

            if(s<=1) {
                break;
            }
            best = min(cost,best);
        }

        if(best <= p) {
            l = d;
        }
        else {
            u = d;
        }
    }
    cout << l;
}


#include <iostream>
#include <cstdio>
#include <vector>
using namespace std;

#define ll                      long long

#define inc(i,a,b)              for(int i=a;i<=b;++i)
#define dec(i,a,b)              for(int i=a;i>=b;--i)

#define pb                      push_back
#define sz(arr)                 ((int)(arr.size()))

const int maxM = 1e5+5;

int m, k, p, e;
vector<int> adj[maxM];
int lev[maxM], cap[maxM], cur[maxM];

void dfs(int u) {
    cap[lev[u]]++;
    e = max(e,lev[u]+1);

    inc(i,0,sz(adj[u])-1) {
        int v = adj[u][i];
        if(lev[v]==0) {
            lev[v] = lev[u]+1;
            dfs(v);
        }
    }
}

int main() {
    ios::sync_with_stdio(false);
    cin >> m >> k >> p;

    inc(i,1,m-1) {
        int a, b;
        cin >> a >> b;

        adj[a].pb(b);
        adj[b].pb(a);
    }

    lev[1] = 1;
    dfs(1);

    int l = 0, u = k+1;
    while(u-l>1) {
        int d = (l+u)/2;

        inc(i,1,e-1) cur[i] = 0;
        cur[e] = d;

        ll best = 1e9+7;
        ll cost = 0;

        int s = e, f = e;
        while(1) {
            ll buffer = cur[f];
            int next = s;
            if(next==f) next--;

            cost -= (d-buffer);
            f = f-1;

            while(next>1) {
                if(buffer<=cap[next]-cur[next]) {
                    cur[next] += buffer;
                    cost += buffer*(f-next);
                    buffer -= buffer;
                    break;
                }
                else {
                    cost += (cap[next]-cur[next])*(f-next);
                    buffer -= (cap[next]-cur[next]);
                    cur[next] = cap[next];
                    next--;
                }
            }

            s = next;

            if(s<=1) {
                break;
            }
            best = min(cost,best);
        }

        if(best <= p) {
            l = d;
        }
        else {
            u = d;
        }
    }
    cout << l;
}


#include <iostream>
#include <cstdio>
#include <cstring>
#include <cstdlib>
#include <cmath>
#include <algorithm>
#include <queue>
#include <map>
#include <set>
#include <vector>
#include <string>
#include <stack>
#define INF 0x3f3f3f3f
#define eps 1e-8
using namespace std;
typedef long long LL;
vector <int> gra[100005];
int cnt[100005];
int mxdep=0;

void dfs(int u,int fa,int dep)
{
    ++cnt[dep];
    mxdep=max(mxdep,dep);
    for(int i=0;i<(int)gra[u].size();++i)
    {
        int v=gra[u][i];
        if(v==fa) continue;
        dfs(v,u,dep+1);
    }
}

int sum,p,n,K;
LL cost;
inline int get_val(int C)
{
    return min(sum+(p-cost)/C,n-1LL);
}

int main()
{
    scanf("%d%d%d",&n,&K,&p);
    for(int i=1;i<n;++i)
    {
        int u,v;
        scanf("%d%d",&u,&v);
        gra[u].push_back(v);
        gra[v].push_back(u);
    }
    dfs(1,1,0);
    int l,r=mxdep,C=1;
    sum=cnt[mxdep]; cost=0;
    for(l=r-1;l>0;--l)
    {
        cost+=1LL*C*cnt[l];
        if(cost>=p)
        {
            cost-=1LL*C*cnt[l];
            break;
        }
        sum+=cnt[l];
        ++C;
    }
    int ans=get_val(C);
    for(;r>0;)
    {
        sum-=cnt[r];
        cost-=sum;
        --C; --r;
        for(;l>0;--l)
        {
            cost+=1LL*C*cnt[l];
            if(cost>=p)
            {
                cost-=1LL*C*cnt[l];
                ans=max(ans,get_val(C));
                break;
            }
            sum+=cnt[l];
            ++C;
        }
        if(!l) ans=max(ans,sum);
    }
    printf("%d\n",min(ans,K));
    return 0;
}


#include <iostream>
#include <cstdio>
#include <cstring>
#include <cstdlib>
#include <cmath>
#include <algorithm>
#include <queue>
#include <map>
#include <set>
#include <vector>
#include <string>
#include <stack>
#define INF 0x3f3f3f3f
#define eps 1e-8
using namespace std;
typedef long long LL;
vector <int> gra[100005];
int cnt[100005];
int mxdep=0;

void dfs(int u,int fa,int dep)
{
    ++cnt[dep];
    mxdep=max(mxdep,dep);
    for(int i=0;i<(int)gra[u].size();++i)
    {
        int v=gra[u][i];
        if(v==fa) continue;
        dfs(v,u,dep+1);
    }
}

int sum,p,n,K;
LL cost;
inline int get_val(int C)
{
    return min(sum+(p-cost)/C,n-1LL);
}

int main()
{
    scanf("%d%d%d",&n,&K,&p);
    for(int i=1;i<n;++i)
    {
        int u,v;
        scanf("%d%d",&u,&v);
        gra[u].push_back(v);
        gra[v].push_back(u);
    }
    dfs(1,1,0);
    int l,r=mxdep,C=1;
    sum=cnt[mxdep]; cost=0;
    for(l=r-1;l>0;--l)
    {
        cost+=1LL*C*cnt[l];
        if(cost>=p)
        {
            cost-=1LL*C*cnt[l];
            break;
        }
        sum+=cnt[l];
        ++C;
    }
    int ans=get_val(C);
    for(;r>0;)
    {
        sum-=cnt[r];
        cost-=sum;
        --C; --r;
        for(;l>0;--l)
        {
            cost+=1LL*C*cnt[l];
            if(cost>=p)
            {
                cost-=1LL*C*cnt[l];
                ans=max(ans,get_val(C));
                break;
            }
            sum+=cnt[l];
            ++C;
        }
    }
    printf("%d\n",min(ans,K));
    return 0;
}


#include <iostream>
#include <cstdio>
#include <cstring>
#include <cstdlib>
#include <cmath>
#include <algorithm>
#include <queue>
#include <map>
#include <set>
#include <vector>
#include <string>
#include <stack>
#define INF 0x3f3f3f3f
#define eps 1e-8
using namespace std;
typedef long long LL;
vector <int> gra[100005];
int cnt[100005];
int mxdep=0;

void dfs(int u,int fa,int dep)
{
    ++cnt[dep];
    mxdep=max(mxdep,dep);
    for(int i=0;i<(int)gra[u].size();++i)
    {
        int v=gra[u][i];
        if(v==fa) continue;
        dfs(v,u,dep+1);
    }
}

int sum,p,n,K;
LL cost;
inline int get_val(int C)
{
    return min(sum+(p-cost)/C,n-1LL);
}

int main()
{
    scanf("%d%d%d",&n,&K,&p);
    for(int i=1;i<n;++i)
    {
        int u,v;
        scanf("%d%d",&u,&v);
        gra[u].push_back(v);
        gra[v].push_back(u);
    }
    dfs(1,1,0);
    int l,r=mxdep,C=1;
    sum=cnt[mxdep]; cost=0;
    for(int l=r-1;l>0;--l)
    {
        cost+=1LL*C*cnt[l];
        if(cost>=p)
        {
            cost-=1LL*C*cnt[l];
            break;
        }
        sum+=cnt[l];
        ++C;
    }
    int ans=get_val(C);
    for(;r>0;)
    {
        sum-=cnt[r];
        cost-=sum;
        --C; --r;
        for(;l>0;--l)
        {
            cost+=1LL*C*cnt[l];
            if(cost>=p)
            {
                cost-=1LL*C*cnt[l];
                ans=max(ans,get_val(C));
                break;
            }
            sum+=cnt[l];
            ++C;
        }
    }
    printf("%d\n",min(ans,K));
    return 0;
}


// Author: bill125
// ntr czr
// orz zyx
// using namespace inline

#include <iostream>
#include <cstdio>
#include <cstring>
#include <string>
#include <map>
#include <set>
#include <vector>
#include <algorithm>
#include <climits>
#include <cstdlib>
#include <ctime>
#include <queue>
#include <bitset>

using namespace std;

typedef long long ll;
typedef double db;
typedef pair<int,int> Pair;
#define rep(i,n) for (int i=0; i<n; ++i)
#define repD(i,n) for (int i=n-1; i>=0; --i)
#define For(i,a,b) for (int i=a; i<=b; ++i)
#define ForD(i,a,b) for (int i=a; i>=b; --i)
#define ForE(i,a) for (Edge* i=h[a]; i; i=i->next)
#define forv(i,a) for (unsigned int i=0, ___t=a.size(); i<___t; ++i)
#define ForV(i,a) for (__typeof(a.begin()) i = a.begin();i != a.end();++i)
#define fill(a,b) memset(a,b,sizeof(a))
#define lowbit(a) ((a) & (-(a)))
#define sqr(a) ((a)*(a))
#define pb push_back
#define mp make_pair
#define gi gI()
#define cut puts("===================")

void setIO(string NAME) {
	#ifndef ONLINE_JUDGE
	string in=NAME+".in", out=NAME+".out";freopen(in.c_str(),"r",stdin),freopen(out.c_str(),"w",stdout);
	#endif
}
ll gI() {char c=getchar();while ((c<'0' || c>'9')&&c!='-') c=getchar();ll flag=1,p=0;if (c=='-') flag=-1,c=getchar();while (c>='0' && c<='9') p=p*10+(c-'0'),c=getchar();return p*flag;}
int gs(char *C) {char c=getchar();while (c==' ' || c=='\n') c=getchar();int l=0;while (c!=' ' && c!='\n') C[l++]=c,c=getchar();C[l]=0;return l;}
template <class T> void debug (const T a,const int & n) {rep(i,n) printf("%d%c", a[i],(i==n-1)?'\n':' ');}

const int inf=~0U>>1, maxn=100000+10;
int n;
ll m,p;
ll c[maxn], q[maxn], d[maxn], s[maxn];
bool v[maxn];

struct Edge {
	int y;
	Edge *next;
	Edge (int _y, Edge *_next) : y(_y), next(_next) {}
}*h[maxn];

void Add_Edge(int x,int y) {
	h[x]=new Edge(y, h[x]);
	h[y]=new Edge(x, h[y]);
}
int main() {
	setIO("test");

	n=gi, m=gi, p=gi;

	rep(i,n-1) {
		int x=gi-1, y=gi-1;
		Add_Edge(x, y);
		Add_Edge(y, x);
	}

	fill(v,0);
	int r=1; q[0]=0, d[0]=1; v[0]=1;
	rep(i,r) {
		int x=q[i];
		ForE(e,x) {
			int y=e->y;
			if (!v[y]) {
				q[r++]=y;
				d[y]=d[x]+1;
				c[d[y]]++;
				v[y]=1;
			}
		}
	}

	ForD(i,n,1) if (c[i]) {r=i;break;}
	For(i,1,r) s[i]+=s[i-1]+c[i];

	int l=r;
	ll now=0, k=0, ans=-1;
	ForD(i,r,1) {
		if (l>i) l=i, now=0;
		while (l>=1 && (ll)(i-l)*c[i]+now<=p) now+=(ll)(i-l)*c[l], k+=c[l--];
		ans=max(ans, k+min(c[l],(ll)(p-now)/(i-l)));
		if (l<i) now-=s[i-1]-s[l], k-=c[i];
	}
	printf("%I64d\n", min(ans, m));

	return 0;
}


// Author: bill125
// ntr czr
// orz zyx
// using namespace inline

#include <iostream>
#include <cstdio>
#include <cstring>
#include <string>
#include <map>
#include <set>
#include <vector>
#include <algorithm>
#include <climits>
#include <cstdlib>
#include <ctime>
#include <queue>
#include <bitset>

using namespace std;

typedef long long ll;
typedef double db;
typedef pair<int,int> Pair;
#define rep(i,n) for (int i=0; i<n; ++i)
#define repD(i,n) for (int i=n-1; i>=0; --i)
#define For(i,a,b) for (int i=a; i<=b; ++i)
#define ForD(i,a,b) for (int i=a; i>=b; --i)
#define ForE(i,a) for (Edge* i=h[a]; i; i=i->next)
#define forv(i,a) for (unsigned int i=0, ___t=a.size(); i<___t; ++i)
#define ForV(i,a) for (__typeof(a.begin()) i = a.begin();i != a.end();++i)
#define fill(a,b) memset(a,b,sizeof(a))
#define lowbit(a) ((a) & (-(a)))
#define sqr(a) ((a)*(a))
#define pb push_back
#define mp make_pair
#define gi gI()
#define cut puts("===================")

void setIO(string NAME) {
	#ifndef ONLINE_JUDGE
	string in=NAME+".in", out=NAME+".out";freopen(in.c_str(),"r",stdin),freopen(out.c_str(),"w",stdout);
	#endif
}
ll gI() {char c=getchar();while ((c<'0' || c>'9')&&c!='-') c=getchar();ll flag=1,p=0;if (c=='-') flag=-1,c=getchar();while (c>='0' && c<='9') p=p*10+(c-'0'),c=getchar();return p*flag;}
int gs(char *C) {char c=getchar();while (c==' ' || c=='\n') c=getchar();int l=0;while (c!=' ' && c!='\n') C[l++]=c,c=getchar();C[l]=0;return l;}
template <class T> void debug (const T a,const int & n) {rep(i,n) printf("%d%c", a[i],(i==n-1)?'\n':' ');}

const int inf=~0U>>1, maxn=100000+10;
int n;
ll m,p;
ll c[maxn], q[maxn], d[maxn], s[maxn];
bool v[maxn];

struct Edge {
	int y;
	Edge *next;
	Edge (int _y, Edge *_next) : y(_y), next(_next) {}
}*h[maxn];

void Add_Edge(int x,int y) {
	h[x]=new Edge(y, h[x]);
	h[y]=new Edge(x, h[y]);
}
int main() {
	setIO("test");

	n=gi, m=gi, p=gi;

	rep(i,n-1) {
		int x=gi-1, y=gi-1;
		Add_Edge(x, y);
		Add_Edge(y, x);
	}

	fill(v,0);
	int r=1; q[0]=0, d[0]=1; v[0]=1;
	rep(i,r) {
		int x=q[i];
		ForE(e,x) {
			int y=e->y;
			if (!v[y]) {
				q[r++]=y;
				d[y]=d[x]+1;
				c[d[y]]++;
				v[y]=1;
			}
		}
	}

	ForD(i,n,1) if (c[i]) {r=i;break;}
	For(i,1,r) s[i]+=s[i-1]+c[i];
	//For(i,1,r) printf("%lld\n", c[i]);

	int l=r;
	ll now=0, k=0, ans=-1;
	ForD(i,r,1) {
		if (l>i) l=i, now=0;
		while (l>=1 && (ll)(i-l)*c[l]+now<=p) now+=(ll)(i-l)*c[l], k+=c[l--];
		ans=max(ans, k+min(c[l],(ll)(p-now)/(i-l)));
	//	if (k+min(c[l],(ll)(p-now)/(i-l))==67) printf("%d %d\n", l, i);
		if (l<i) now-=s[i-1]-s[l], k-=c[i];
	}
	printf("%I64d\n", min(ans, m));

	return 0;
}


// Author: bill125
// ntr czr
// orz zyx
// using namespace inline

#include <iostream>
#include <cstdio>
#include <cstring>
#include <string>
#include <map>
#include <set>
#include <vector>
#include <algorithm>
#include <climits>
#include <cstdlib>
#include <ctime>
#include <queue>
#include <bitset>

using namespace std;

typedef long long ll;
typedef double db;
typedef pair<int,int> Pair;
#define rep(i,n) for (int i=0; i<n; ++i)
#define repD(i,n) for (int i=n-1; i>=0; --i)
#define For(i,a,b) for (int i=a; i<=b; ++i)
#define ForD(i,a,b) for (int i=a; i>=b; --i)
#define ForE(i,a) for (Edge* i=h[a]; i; i=i->next)
#define forv(i,a) for (unsigned int i=0, ___t=a.size(); i<___t; ++i)
#define ForV(i,a) for (__typeof(a.begin()) i = a.begin();i != a.end();++i)
#define fill(a,b) memset(a,b,sizeof(a))
#define lowbit(a) ((a) & (-(a)))
#define sqr(a) ((a)*(a))
#define pb push_back
#define mp make_pair
#define gi gI()
#define cut puts("===================")

void setIO(string NAME) {
	#ifndef ONLINE_JUDGE
	string in=NAME+".in", out=NAME+".out";freopen(in.c_str(),"r",stdin),freopen(out.c_str(),"w",stdout);
	#endif
}
ll gI() {char c=getchar();while ((c<'0' || c>'9')&&c!='-') c=getchar();ll flag=1,p=0;if (c=='-') flag=-1,c=getchar();while (c>='0' && c<='9') p=p*10+(c-'0'),c=getchar();return p*flag;}
int gs(char *C) {char c=getchar();while (c==' ' || c=='\n') c=getchar();int l=0;while (c!=' ' && c!='\n') C[l++]=c,c=getchar();C[l]=0;return l;}
template <class T> void debug (const T a,const int & n) {rep(i,n) printf("%d%c", a[i],(i==n-1)?'\n':' ');}

const int inf=~0U>>1, maxn=100000+10;
int n;
ll m,p;
ll c[maxn], q[maxn], d[maxn], s[maxn];
bool v[maxn];

struct Edge {
	int y;
	Edge *next;
	Edge (int _y, Edge *_next) : y(_y), next(_next) {}
}*h[maxn];

void Add_Edge(int x,int y) {
	h[x]=new Edge(y, h[x]);
	h[y]=new Edge(x, h[y]);
}
int main() {
	setIO("test");

	n=gi, m=gi, p=gi;

	rep(i,n-1) {
		int x=gi-1, y=gi-1;
		Add_Edge(x, y);
		Add_Edge(y, x);
	}

	int r=1; q[0]=0, d[0]=1; v[0]=1;
	rep(i,r) {
		int x=q[i];
		ForE(e,x) {
			int y=e->y;
			if (!v[y]) {
				q[r++]=y;
				d[y]=d[x]+1;
				c[d[y]]++;
				v[y]=1;
			}
		}
	}

	ForD(i,n,1) if (c[i]) {r=i;break;};
	For(i,1,r) s[i]+=s[i-1]+c[i];

//	For(i,1,r) printf("%lld\n", c[i]);

	int l=r;
	ll now=0, k=0, ans=-1;
	ForD(i,r,1) {
		if (l>i) l=i, now=0;
		while (l>=1 && (ll)(i-l)*c[i]+now<p) now+=(ll)(i-l)*c[l], k+=c[l--];
	//	printf(" %d %d %I64d\n", i, l, now);
		ans=max(ans, k+min(c[l],(p-now)/(i-l)));
		//if (k+min(c[l],(p-now)/(i-l+1))==5) printf("%d %d\n", l, i);
		if (l<i) now-=s[i-1]-s[l], k-=c[i];
	}
	printf("%I64d\n", min(ans, m));

	return 0;
}


#include<iostream>
#include<cstring>
#include<cstdio>
#include<cstdlib>
#include<algorithm>
using namespace std;
const int N=10005;
typedef long long ll;
struct arr{
	int y,nex;
}g[N*3];
int n,pos[N],a[N],sz,nn;
long long m,p,sum[N],h[N],b[N],ans;
void init(int x,int y)
{
	g[++sz].y=y;
	g[sz].nex=pos[x];
	pos[x]=sz;
}
void dfs(int fat,int x,int y)
{//cout<<y;
	for(int i=pos[x];i;i=g[i].nex){
		int yy=g[i].y;
		if(yy!=fat){
			dfs(x,yy,y+1);
		}
	}
	h[y]++;
	nn=max(y,nn);
}
int main()
{
	int x,y;
	cin>>n>>m>>p;
	for(int i=1;i<n;i++){
		scanf("%d%d",&x,&y);
		init(x,y);
		init(y,x);
	}
	dfs(1,1,0);
	//cout<<1;
//	for(int i=1;i<=nn;i++)cout<<h[i]<<endl;
	int s=0;
	for(int i=1;i<=nn;i++){
		sum[i]=sum[i-1]+s;
		b[i]+=b[i-1]+h[i];
		s+=h[i];
		a[i]=s;
	}
	//cout<<nn<<endl;
	h[0]=0;
	for(int i=1;i<=nn;i++){
		long long l=1,r=i+1,t,res;
		while(l!=r){
			int mid=(l+r)/2;
			t=sum[i]-sum[mid]-ll(i-mid)*a[mid-1];
			if(t<=p)r=mid;
			else l=mid+1;
			//cout<<l<<" "<<r<<endl;
		}
		//cout<<i<<" "<<l<<endl;
		t=sum[i]-sum[l]-(i-l)*a[l-1];
		res=min((p-t)/(i-l+1),h[l-1]);
		int pp=res+b[i]-b[l-1];
		if(pp>ans)ans=min(pp,m);
	}
	cout<<ans<<endl;

    //system("pause");
	return 0;
}


#include<iostream>
#include<cstring>
#include<cstdio>
#include<cstdlib>
#include<algorithm>
using namespace std;
const int N=10005;
typedef long long ll;
struct arr{
	int y,nex;
}g[N*3];
int m,n,pos[N],sz,nn,ans;
long long p,sum[N],h[N],a[N];
int b[N];
void init(int x,int y)
{
	g[++sz].y=y;
	g[sz].nex=pos[x];
	pos[x]=sz;
}
void dfs(int fat,int x,int y)
{//cout<<y;
	for(int i=pos[x];i;i=g[i].nex){
		int yy=g[i].y;
		if(yy!=fat){
			dfs(x,yy,y+1);
		}
	}
	h[y]++;
	nn=max(y,nn);
}
int main()
{
	int x,y;
	cin>>n>>m>>p;
	for(int i=1;i<n;i++){
		scanf("%d%d",&x,&y);
		init(x,y);
		init(y,x);
	}
	dfs(1,1,0);
	//cout<<1;
//	for(int i=1;i<=nn;i++)cout<<h[i]<<endl;
/*	ll s=0;*/
	for(int i=1;i<=nn;i++){
		//sum[i]=sum[i-1]+s;
		b[i]+=b[i-1]+h[i];
	//	s+=h[i];
	//	a[i]=s;
	}
	//cout<<nn<<endl;
	h[0]=0;
	int s=0,l=1,cs=0;
	int res;
	for(int i=1;i<=nn;i++){
		if(cs>p){
			while(cs>p){
				cs-=h[l]*(i-l);
				s-=h[l];l++;
			}
		}
		res=min((p-cs)/(i-l+1),h[l-1]);
		int pp=res+b[i]-b[l-1];
	//	cout<<pp<<endl;
		if(pp>ans)ans=min(m,pp);
		s+=h[i];
		cs+=s;
	}
	/*for(ll i=1;i<=nn;i++){
		long long l=1,r=i+1,t,res;
		while(l!=r){
			long long mid=(l+r)/2;
			t=sum[i]-sum[mid]-ll(i-mid)*a[mid-1];
			if(t<=p)r=mid;
			else l=mid+1;
			//cout<<l<<" "<<r<<endl;
		}
		//cout<<i<<" "<<l<<endl;
		t=sum[i]-sum[l]-(i-l)*a[l-1];
		res=min((p-t)/(i-l+1),h[l-1]);
		int pp=res+b[i]-b[l-1];
		if(pp>ans)ans=min(pp,m);
	}*/
	cout<<ans<<endl;

  /// // system("pause");
	return 0;
}


#include<iostream>
#include<cstring>
#include<cstdio>
#include<cstdlib>
#include<algorithm>
using namespace std;
const int N=10005;
typedef long long ll;
struct arr{
	int y,nex;
}g[N*3];
int m,n,pos[N],sz,nn,ans;
long long p,sum[N],h[N],b[N],a[N];
void init(int x,int y)
{
	g[++sz].y=y;
	g[sz].nex=pos[x];
	pos[x]=sz;
}
void dfs(int fat,int x,int y)
{//cout<<y;
	for(int i=pos[x];i;i=g[i].nex){
		int yy=g[i].y;
		if(yy!=fat){
			dfs(x,yy,y+1);
		}
	}
	h[y]++;
	nn=max(y,nn);
}
int main()
{
	int x,y;
	cin>>n>>m>>p;
	for(int i=1;i<n;i++){
		scanf("%d%d",&x,&y);
		init(x,y);
		init(y,x);
	}
	dfs(1,1,0);
	//cout<<1;
//	for(int i=1;i<=nn;i++)cout<<h[i]<<endl;
	ll s=0;
	for(int i=1;i<=nn;i++){
		sum[i]=sum[i-1]+s;
		b[i]+=b[i-1]+h[i];
		s+=h[i];
		a[i]=s;
	}
	//cout<<nn<<endl;
	h[0]=0;
	for(ll i=1;i<=nn;i++){
		long long l=1,r=i+1,t,res;
		while(l!=r){
			long long mid=(l+r)/2;
			t=sum[i]-sum[mid]-ll(i-mid)*a[mid-1];
			if(t<=p)r=mid;
			else l=mid+1;
			//cout<<l<<" "<<r<<endl;
		}
		//cout<<i<<" "<<l<<endl;
		t=sum[i]-sum[l]-(i-l)*a[l-1];
		res=min((p-t)/(i-l+1),h[l-1]);
		int pp=res+b[i]-b[l-1];
		if(pp>ans)ans=min(pp,m);
	}
	cout<<ans<<endl;

    //system("pause");
	return 0;
}


#include<iostream>
#include<cstring>
#include<cstdio>
#include<cstdlib>
#include<algorithm>
using namespace std;
const int N=10005;
struct arr{
	int y,nex;
}g[N*3];
int n,m,p,pos[N],a[N],sum[N],sz,h[N],b[N],ans,nn;
void init(int x,int y)
{
	g[++sz].y=y;
	g[sz].nex=pos[x];
	pos[x]=sz;
}
void dfs(int fat,int x,int y)
{//cout<<y;
	for(int i=pos[x];i;i=g[i].nex){
		int yy=g[i].y;
		if(yy!=fat){
			dfs(x,yy,y+1);
		}
	}
	h[y]++;
	nn=max(y,nn);
}
int main()
{
	int x,y;
	cin>>n>>m>>p;
	for(int i=1;i<n;i++){
		scanf("%d%d",&x,&y);
		init(x,y);
		init(y,x);
	}
	dfs(1,1,0);
	//cout<<1;
//	for(int i=1;i<=nn;i++)cout<<h[i]<<endl;
	int s=0;
	for(int i=1;i<=nn;i++){
		sum[i]=sum[i-1]+s;
		b[i]+=b[i-1]+h[i];
		s+=h[i];
		a[i]=s;
	}
	//cout<<nn<<endl;
	h[0]=0;
	for(int i=1;i<=nn;i++){
		int l=1,r=i+1,t,res;
		while(l!=r){
			int mid=(l+r)/2;
			t=sum[i]-sum[mid]-(i-mid)*a[mid-1];
			if(t<=p)r=mid;
			else l=mid+1;
			//cout<<l<<" "<<r<<endl;
		}
		//cout<<i<<" "<<l<<endl;
		t=sum[i]-sum[l]-(i-l)*a[l-1];
		res=min((p-t)/(i-l+1),h[l-1]);
		int pp=res+b[i]-b[l-1];
		if(pp>ans)ans=min(pp,m);
	}
	cout<<ans<<endl;

    //system("pause");
	return 0;
}