/// Syed Shahriar Manjur (Dip)
//#pragma warning (disable: 4786)

#include <sstream>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <cstdio>
#include <cstdlib>
#include <cctype>
#include <complex>
#include <cmath>
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <bitset>
#include <list>
#include <string.h>
#include <assert.h>
#include  <time.h>
using namespace std;
#define print1(a)    cout<<a<<endl
#define print2(a,b) cout<<a<<" "<<b<<endl
#define print3(a,b,c) cout<<a<<" "<<b<<" "<<c<<endl
#define oo          (1<<30)
#define PI          3.141592653589793
#define pi          (2.0*acos(0.0))
#define ERR         1e-5
#define PRE         1e-8
#define SZ(s)       ((int)s.size())
#define LL          long long
#define ISS         istringstream
#define OSS         ostringstream
#define VS          vector<string>
#define VI          vector<int>
#define VD          vector<double>
#define VLL         vector<long long>
#define SII         set<int>::iterator
#define SI          set<int>
#define mem(a,b)    memset(a,b,sizeof(a))
#define fr(i,a,b)   for(i=a;i<=b;i++)
#define frn(i,a,b)  for(i=a;i>=b;i--)
#define fri(a,b)    for(i=a;i<=b;i++)
#define frin(a,b)   for(i=a;i>=b;i--)
#define frj(a,b)    for(j=a;j<=b;j++)
#define frjn(a,b)   for(j=a;j>=b;j--)
#define frk(a,b)    for(k=a;k<=b;k++)
#define frkn(a,b)   for(k=a;k>=b;k--)
#define frl(a,b)    for(l=a;l<=b;l++)
#define frln(a,b)   for(l=a;l>=b;l--)
#define REP(i,n)    for(i=0;i<n;i++)
#define EQ(a,b)     (fabs(a-b)<ERR)
#define all(a,b,c)  for(int I=0;I<b;I++)    a[I] = c
#define CROSS(a,b,c,d) ((b.x-a.x)*(d.y-c.y)-(d.x-c.x)*(b.y-a.y))
#define sqr(a)      ((a)*(a))
#define FORE(i,a)   for(typeof((a).begin())i=(a).begin();i!=(a).end();i++)
#define typing(j,b) typeof((b).begin()) j=(b).begin();
#define BE(a)       a.begin(),a.end()
#define rev(a)      reverse(BE(a));
#define sorta(a)    sort(BE(a))
#define pb          push_back
#define popb        pop_back
#define mp          make_pair
#define round(i,a)  i = ( a < 0 ) ? a - 0.5 : a + 0.5;
#define makeint(n,s)  istringstream(s)>>n
#define inpow(a,x,y) int i; a=x;fri(2,y)  a*=x
#define cntbit(mask) __builtin_popcountll(mask)
//0 based print
#define debug_array(a,n) for(int i=1;i<=n;i++) cerr<<a[i]<<" "; cerr<<endl;
#define debug_matrix(mat,row,col) for(int i=0;i<row;i++) {for(int j=0;j<col;j++) cerr<<mat[i][j]<<" ";cerr<<endl;}

#define csprnt printf("Case %d: ", ++cas);
#define mod         1000000007
#define eulerconstant 0.5772156649

template<class T1> void debug(T1 e){cout<<e<<endl;}
template<class T1,class T2> void debug(T1 e1,T2 e2){cout<<e1<<"\t"<<e2<<endl;}
template<class T1,class T2,class T3> void debug(T1 e1,T2 e2,T3 e3){cout<<e1<<"\t"<<e2<<"\t"<<e3<<endl;}
template<class T1,class T2,class T3,class T4> void debug(T1 e1,T2 e2,T3 e3,T4 e4){cout<<e1<<"\t"<<e2<<"\t"<<e3<<"\t"<<e4<<endl;}
template<class T1,class T2,class T3,class T4,class T5> void debug(T1 e1,T2 e2,T3 e3,T4 e4,T5 e5){cout<<e1<<"\t"<<e2<<"\t"<<e3<<"\t"<<e4<<"\t"<<e5<<endl;}
template<class T1,class T2,class T3,class T4,class T5,class T6> void debug(T1 e1,T2 e2,T3 e3,T4 e4,T5 e5,T6 e6){cout<<e1<<"\t"<<e2<<"\t"<<e3<<"\t"<<e4<<"\t"<<e5<<"\t"<<e6<<endl;}
template<class T> void debug(vector< vector<T> > e,int row,int col){int i,j;REP(i,row) {REP(j,col) cout<<e[i][j]<<" ";cout<<endl;} cout<<endl;}
template<class T> void debug(vector< basic_string<T> > e,int row,int col){int i,j;REP(i,row) {REP(j,col) cout<<e[i][j];cout<<endl;} cout<<endl;}
template<class T> void debug(T e[110][110],int row,int col){int i,j;REP(i,row) {REP(j,col) cout<<e[i][j]<<" ";cout<<endl;}}
template<class T> string toString(T n){ostringstream oss;oss<<n;oss.flush();return oss.str();}
int toInt(string s){int r=0;istringstream sin(s);sin>>r;return r;}
bool isVowel(char ch){ch=tolower(ch);if(ch=='a' || ch=='e' || ch=='i' || ch=='o' || ch=='u')return true;return false;}
bool isUpper(char c){return c>='A' && c<='Z';}
bool isLower(char c){return c>='a' && c<='z';}
//*************************************************My Code Starts Here*********************************************************************************
#define lim 110000
int m,k,p;
VI adj[lim];
int hei[lim];
int cumhei[lim];
int maxhei;

void dfs(int node,int par,int h)
{
    hei[h]++;
    int i;
    fr(i,0,SZ(adj[node])-1)
    {
        int tem=adj[node][i];
        if(tem==par) continue;
        dfs(tem,node,h+1);
    }
    maxhei=max(h,maxhei);
}

int main()
{
    //srand(time(NULL));
    //freopen("A.txt","r",stdin);
    //freopen("B.txt","w",stdout);
    while(cin>>m>>k>>p)
    {
        int i;
        int a,b;
        fr(i,1,m)
            adj[i].clear();
        fr(i,1,m-1)
        {
            scanf("%d %d",&a,&b);
            adj[a].pb(b);
            adj[b].pb(a);
        }

        mem(hei,0);
        maxhei=0;
        dfs(1,-1,1);
        cumhei[maxhei+1]=0;
        for(i=maxhei;i>=2;i--)
            cumhei[i]=cumhei[i+1]+hei[i];
        int j=maxhei;
        int cost=0;
        int ans=0;
        k=min(k,m-1);
        for(i=maxhei;i>=2;i--)
        {
            int totalnode=0;
            while(j>=2)
            {
                int costlimit = k;
                if(i>j) costlimit=(p-cost)/(i-j);
                int nodelimit = min(hei[j],k-(cumhei[j+1]-cumhei[i+1]));
                int addnode = min(costlimit,nodelimit);
                if(addnode<=0) break;
                totalnode += addnode;
                cost += addnode*(i-j);
                j--;
            }

            ans = max(ans,totalnode);
            cost -= totalnode-hei[i];
        }
        print1(ans);
    }
    return 0;
}


/// Syed Shahriar Manjur (Dip)
//#pragma warning (disable: 4786)

#include <sstream>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <cstdio>
#include <cstdlib>
#include <cctype>
#include <complex>
#include <cmath>
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <bitset>
#include <list>
#include <string.h>
#include <assert.h>
#include  <time.h>
using namespace std;
#define print1(a)    cout<<a<<endl
#define print2(a,b) cout<<a<<" "<<b<<endl
#define print3(a,b,c) cout<<a<<" "<<b<<" "<<c<<endl
#define oo          (1<<30)
#define PI          3.141592653589793
#define pi          (2.0*acos(0.0))
#define ERR         1e-5
#define PRE         1e-8
#define SZ(s)       ((int)s.size())
#define LL          long long
#define ISS         istringstream
#define OSS         ostringstream
#define VS          vector<string>
#define VI          vector<int>
#define VD          vector<double>
#define VLL         vector<long long>
#define SII         set<int>::iterator
#define SI          set<int>
#define mem(a,b)    memset(a,b,sizeof(a))
#define fr(i,a,b)   for(i=a;i<=b;i++)
#define frn(i,a,b)  for(i=a;i>=b;i--)
#define fri(a,b)    for(i=a;i<=b;i++)
#define frin(a,b)   for(i=a;i>=b;i--)
#define frj(a,b)    for(j=a;j<=b;j++)
#define frjn(a,b)   for(j=a;j>=b;j--)
#define frk(a,b)    for(k=a;k<=b;k++)
#define frkn(a,b)   for(k=a;k>=b;k--)
#define frl(a,b)    for(l=a;l<=b;l++)
#define frln(a,b)   for(l=a;l>=b;l--)
#define REP(i,n)    for(i=0;i<n;i++)
#define EQ(a,b)     (fabs(a-b)<ERR)
#define all(a,b,c)  for(int I=0;I<b;I++)    a[I] = c
#define CROSS(a,b,c,d) ((b.x-a.x)*(d.y-c.y)-(d.x-c.x)*(b.y-a.y))
#define sqr(a)      ((a)*(a))
#define FORE(i,a)   for(typeof((a).begin())i=(a).begin();i!=(a).end();i++)
#define typing(j,b) typeof((b).begin()) j=(b).begin();
#define BE(a)       a.begin(),a.end()
#define rev(a)      reverse(BE(a));
#define sorta(a)    sort(BE(a))
#define pb          push_back
#define popb        pop_back
#define mp          make_pair
#define round(i,a)  i = ( a < 0 ) ? a - 0.5 : a + 0.5;
#define makeint(n,s)  istringstream(s)>>n
#define inpow(a,x,y) int i; a=x;fri(2,y)  a*=x
#define cntbit(mask) __builtin_popcountll(mask)
//0 based print
#define debug_array(a,n) for(int i=1;i<=n;i++) cerr<<a[i]<<" "; cerr<<endl;
#define debug_matrix(mat,row,col) for(int i=0;i<row;i++) {for(int j=0;j<col;j++) cerr<<mat[i][j]<<" ";cerr<<endl;}

#define csprnt printf("Case %d: ", ++cas);
#define mod         1000000007
#define eulerconstant 0.5772156649

template<class T1> void debug(T1 e){cout<<e<<endl;}
template<class T1,class T2> void debug(T1 e1,T2 e2){cout<<e1<<"\t"<<e2<<endl;}
template<class T1,class T2,class T3> void debug(T1 e1,T2 e2,T3 e3){cout<<e1<<"\t"<<e2<<"\t"<<e3<<endl;}
template<class T1,class T2,class T3,class T4> void debug(T1 e1,T2 e2,T3 e3,T4 e4){cout<<e1<<"\t"<<e2<<"\t"<<e3<<"\t"<<e4<<endl;}
template<class T1,class T2,class T3,class T4,class T5> void debug(T1 e1,T2 e2,T3 e3,T4 e4,T5 e5){cout<<e1<<"\t"<<e2<<"\t"<<e3<<"\t"<<e4<<"\t"<<e5<<endl;}
template<class T1,class T2,class T3,class T4,class T5,class T6> void debug(T1 e1,T2 e2,T3 e3,T4 e4,T5 e5,T6 e6){cout<<e1<<"\t"<<e2<<"\t"<<e3<<"\t"<<e4<<"\t"<<e5<<"\t"<<e6<<endl;}
template<class T> void debug(vector< vector<T> > e,int row,int col){int i,j;REP(i,row) {REP(j,col) cout<<e[i][j]<<" ";cout<<endl;} cout<<endl;}
template<class T> void debug(vector< basic_string<T> > e,int row,int col){int i,j;REP(i,row) {REP(j,col) cout<<e[i][j];cout<<endl;} cout<<endl;}
template<class T> void debug(T e[110][110],int row,int col){int i,j;REP(i,row) {REP(j,col) cout<<e[i][j]<<" ";cout<<endl;}}
template<class T> string toString(T n){ostringstream oss;oss<<n;oss.flush();return oss.str();}
int toInt(string s){int r=0;istringstream sin(s);sin>>r;return r;}
bool isVowel(char ch){ch=tolower(ch);if(ch=='a' || ch=='e' || ch=='i' || ch=='o' || ch=='u')return true;return false;}
bool isUpper(char c){return c>='A' && c<='Z';}
bool isLower(char c){return c>='a' && c<='z';}
//*************************************************My Code Starts Here*********************************************************************************
#define lim 110000
int m,k,p;
VI adj[lim];
int hei[lim];
int cumhei[lim];
int maxhei;

void dfs(int node,int par,int h)
{
    hei[h]++;
    int i;
    fr(i,0,SZ(adj[node])-1)
    {
        int tem=adj[node][i];
        if(tem==par) continue;
        dfs(tem,node,h+1);
    }
    maxhei=max(h,maxhei);
}

int main()
{
    //srand(time(NULL));
    //freopen("A.txt","r",stdin);
    //freopen("B.txt","w",stdout);
    while(cin>>m>>k>>p)
    {
        int i;
        int a,b;
        fr(i,1,m)
            adj[i].clear();
        fr(i,1,m-1)
        {
            scanf("%d %d",&a,&b);
            adj[a].pb(b);
            adj[b].pb(a);
        }

        mem(hei,0);
        maxhei=0;
        dfs(1,-1,1);
        cumhei[maxhei+1]=0;
        for(i=maxhei;i>=2;i--)
            cumhei[i]=cumhei[i+1]+hei[i];
        int j=maxhei;
        int cost=0;
        int ans=0;
        k=min(k,m-1);
        for(i=maxhei;i>=2;i--)
        {
            int totalnode=0;
            while(j>=2)
            {
                int costlimit = k;
                if(i>j) costlimit=(p-cost)/(i-j);
                int nodelimit = min(hei[j],k-(cumhei[j+1]-cumhei[i+1]));
                int addnode = min(costlimit,nodelimit);
                if(addnode<=0) break;
                totalnode += addnode;
                cost += addnode*(i-j);
                if(addnode<hei[j]) break;
                j--;
            }
            if(j<=1) totalnode = cumhei[2]-cumhei[i+1];

            ans = max(ans,totalnode);
            cost -= totalnode-hei[i];
        }
        print1(ans);
    }
    return 0;
}


/// Syed Shahriar Manjur (Dip)
//#pragma warning (disable: 4786)

#include <sstream>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <cstdio>
#include <cstdlib>
#include <cctype>
#include <complex>
#include <cmath>
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <bitset>
#include <list>
#include <string.h>
#include <assert.h>
#include  <time.h>
using namespace std;
#define print1(a)    cout<<a<<endl
#define print2(a,b) cout<<a<<" "<<b<<endl
#define print3(a,b,c) cout<<a<<" "<<b<<" "<<c<<endl
#define oo          (1<<30)
#define PI          3.141592653589793
#define pi          (2.0*acos(0.0))
#define ERR         1e-5
#define PRE         1e-8
#define SZ(s)       ((int)s.size())
#define LL          long long
#define ISS         istringstream
#define OSS         ostringstream
#define VS          vector<string>
#define VI          vector<int>
#define VD          vector<double>
#define VLL         vector<long long>
#define SII         set<int>::iterator
#define SI          set<int>
#define mem(a,b)    memset(a,b,sizeof(a))
#define fr(i,a,b)   for(i=a;i<=b;i++)
#define frn(i,a,b)  for(i=a;i>=b;i--)
#define fri(a,b)    for(i=a;i<=b;i++)
#define frin(a,b)   for(i=a;i>=b;i--)
#define frj(a,b)    for(j=a;j<=b;j++)
#define frjn(a,b)   for(j=a;j>=b;j--)
#define frk(a,b)    for(k=a;k<=b;k++)
#define frkn(a,b)   for(k=a;k>=b;k--)
#define frl(a,b)    for(l=a;l<=b;l++)
#define frln(a,b)   for(l=a;l>=b;l--)
#define REP(i,n)    for(i=0;i<n;i++)
#define EQ(a,b)     (fabs(a-b)<ERR)
#define all(a,b,c)  for(int I=0;I<b;I++)    a[I] = c
#define CROSS(a,b,c,d) ((b.x-a.x)*(d.y-c.y)-(d.x-c.x)*(b.y-a.y))
#define sqr(a)      ((a)*(a))
#define FORE(i,a)   for(typeof((a).begin())i=(a).begin();i!=(a).end();i++)
#define typing(j,b) typeof((b).begin()) j=(b).begin();
#define BE(a)       a.begin(),a.end()
#define rev(a)      reverse(BE(a));
#define sorta(a)    sort(BE(a))
#define pb          push_back
#define popb        pop_back
#define mp          make_pair
#define round(i,a)  i = ( a < 0 ) ? a - 0.5 : a + 0.5;
#define makeint(n,s)  istringstream(s)>>n
#define inpow(a,x,y) int i; a=x;fri(2,y)  a*=x
#define cntbit(mask) __builtin_popcountll(mask)
//0 based print
#define debug_array(a,n) for(int i=1;i<=n;i++) cerr<<a[i]<<" "; cerr<<endl;
#define debug_matrix(mat,row,col) for(int i=0;i<row;i++) {for(int j=0;j<col;j++) cerr<<mat[i][j]<<" ";cerr<<endl;}

#define csprnt printf("Case %d: ", ++cas);
#define mod         1000000007
#define eulerconstant 0.5772156649

template<class T1> void debug(T1 e){cout<<e<<endl;}
template<class T1,class T2> void debug(T1 e1,T2 e2){cout<<e1<<"\t"<<e2<<endl;}
template<class T1,class T2,class T3> void debug(T1 e1,T2 e2,T3 e3){cout<<e1<<"\t"<<e2<<"\t"<<e3<<endl;}
template<class T1,class T2,class T3,class T4> void debug(T1 e1,T2 e2,T3 e3,T4 e4){cout<<e1<<"\t"<<e2<<"\t"<<e3<<"\t"<<e4<<endl;}
template<class T1,class T2,class T3,class T4,class T5> void debug(T1 e1,T2 e2,T3 e3,T4 e4,T5 e5){cout<<e1<<"\t"<<e2<<"\t"<<e3<<"\t"<<e4<<"\t"<<e5<<endl;}
template<class T1,class T2,class T3,class T4,class T5,class T6> void debug(T1 e1,T2 e2,T3 e3,T4 e4,T5 e5,T6 e6){cout<<e1<<"\t"<<e2<<"\t"<<e3<<"\t"<<e4<<"\t"<<e5<<"\t"<<e6<<endl;}
template<class T> void debug(vector< vector<T> > e,int row,int col){int i,j;REP(i,row) {REP(j,col) cout<<e[i][j]<<" ";cout<<endl;} cout<<endl;}
template<class T> void debug(vector< basic_string<T> > e,int row,int col){int i,j;REP(i,row) {REP(j,col) cout<<e[i][j];cout<<endl;} cout<<endl;}
template<class T> void debug(T e[110][110],int row,int col){int i,j;REP(i,row) {REP(j,col) cout<<e[i][j]<<" ";cout<<endl;}}
template<class T> string toString(T n){ostringstream oss;oss<<n;oss.flush();return oss.str();}
int toInt(string s){int r=0;istringstream sin(s);sin>>r;return r;}
bool isVowel(char ch){ch=tolower(ch);if(ch=='a' || ch=='e' || ch=='i' || ch=='o' || ch=='u')return true;return false;}
bool isUpper(char c){return c>='A' && c<='Z';}
bool isLower(char c){return c>='a' && c<='z';}
//*************************************************My Code Starts Here*********************************************************************************
#define lim 110000
int m,k,p;
VI adj[lim];
int hei[lim];
int cumhei[lim];
int maxhei;

void dfs(int node,int par,int h)
{
    hei[h]++;
    int i;
    fr(i,0,SZ(adj[node])-1)
    {
        int tem=adj[node][i];
        if(tem==par) continue;
        dfs(tem,node,h+1);
    }
    maxhei=max(h,maxhei);
}

int main()
{
    //srand(time(NULL));
    //freopen("A.txt","r",stdin);
    //freopen("B.txt","w",stdout);
    while(cin>>m>>k>>p)
    {
        int i;
        int a,b;
        fr(i,1,m)
            adj[i].clear();
        fr(i,1,m-1)
        {
            scanf("%d %d",&a,&b);
            adj[a].pb(b);
            adj[b].pb(a);
        }

        mem(hei,0);
        maxhei=0;
        dfs(1,-1,1);
        cumhei[maxhei+1]=0;
        for(i=maxhei;i>=2;i--)
            cumhei[i]=cumhei[i+1]+hei[i];
        int j=maxhei;
        int cost=0;
        int ans=0;
        k=min(k,m-1);
        for(i=maxhei;i>=2;i--)
        {
            if(j<i) { j=i; cost=0; }
            int totalnode=cumhei[j+1]-cumhei[i+1];
            while(j>=2)
            {
                int costlimit = k;
                if(i>j) costlimit=(p-cost)/(i-j);
                int nodelimit = min(hei[j],k-totalnode);
                int addnode = min(costlimit,nodelimit);
                if(addnode<=0) break;
                totalnode += addnode;
                cost += addnode*(i-j);
                if(addnode<hei[j]) break;
                j--;
            }

            ans = max(ans,totalnode);
            if(totalnode>hei[i]) cost -= totalnode-hei[i];
            else cost=0;
        }
        print1(ans);
    }
    return 0;
}


/// Syed Shahriar Manjur (Dip)
//#pragma warning (disable: 4786)

#include <sstream>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <cstdio>
#include <cstdlib>
#include <cctype>
#include <complex>
#include <cmath>
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <bitset>
#include <list>
#include <string.h>
#include <assert.h>
#include  <time.h>
using namespace std;
#define print1(a)    cout<<a<<endl
#define print2(a,b) cout<<a<<" "<<b<<endl
#define print3(a,b,c) cout<<a<<" "<<b<<" "<<c<<endl
#define oo          (1<<30)
#define PI          3.141592653589793
#define pi          (2.0*acos(0.0))
#define ERR         1e-5
#define PRE         1e-8
#define SZ(s)       ((int)s.size())
#define LL          long long
#define ISS         istringstream
#define OSS         ostringstream
#define VS          vector<string>
#define VI          vector<int>
#define VD          vector<double>
#define VLL         vector<long long>
#define SII         set<int>::iterator
#define SI          set<int>
#define mem(a,b)    memset(a,b,sizeof(a))
#define fr(i,a,b)   for(i=a;i<=b;i++)
#define frn(i,a,b)  for(i=a;i>=b;i--)
#define fri(a,b)    for(i=a;i<=b;i++)
#define frin(a,b)   for(i=a;i>=b;i--)
#define frj(a,b)    for(j=a;j<=b;j++)
#define frjn(a,b)   for(j=a;j>=b;j--)
#define frk(a,b)    for(k=a;k<=b;k++)
#define frkn(a,b)   for(k=a;k>=b;k--)
#define frl(a,b)    for(l=a;l<=b;l++)
#define frln(a,b)   for(l=a;l>=b;l--)
#define REP(i,n)    for(i=0;i<n;i++)
#define EQ(a,b)     (fabs(a-b)<ERR)
#define all(a,b,c)  for(int I=0;I<b;I++)    a[I] = c
#define CROSS(a,b,c,d) ((b.x-a.x)*(d.y-c.y)-(d.x-c.x)*(b.y-a.y))
#define sqr(a)      ((a)*(a))
#define FORE(i,a)   for(typeof((a).begin())i=(a).begin();i!=(a).end();i++)
#define typing(j,b) typeof((b).begin()) j=(b).begin();
#define BE(a)       a.begin(),a.end()
#define rev(a)      reverse(BE(a));
#define sorta(a)    sort(BE(a))
#define pb          push_back
#define popb        pop_back
#define mp          make_pair
#define round(i,a)  i = ( a < 0 ) ? a - 0.5 : a + 0.5;
#define makeint(n,s)  istringstream(s)>>n
#define inpow(a,x,y) int i; a=x;fri(2,y)  a*=x
#define cntbit(mask) __builtin_popcountll(mask)
//0 based print
#define debug_array(a,n) for(int i=1;i<=n;i++) cerr<<a[i]<<" "; cerr<<endl;
#define debug_matrix(mat,row,col) for(int i=0;i<row;i++) {for(int j=0;j<col;j++) cerr<<mat[i][j]<<" ";cerr<<endl;}

#define csprnt printf("Case %d: ", ++cas);
#define mod         1000000007
#define eulerconstant 0.5772156649

template<class T1> void debug(T1 e){cout<<e<<endl;}
template<class T1,class T2> void debug(T1 e1,T2 e2){cout<<e1<<"\t"<<e2<<endl;}
template<class T1,class T2,class T3> void debug(T1 e1,T2 e2,T3 e3){cout<<e1<<"\t"<<e2<<"\t"<<e3<<endl;}
template<class T1,class T2,class T3,class T4> void debug(T1 e1,T2 e2,T3 e3,T4 e4){cout<<e1<<"\t"<<e2<<"\t"<<e3<<"\t"<<e4<<endl;}
template<class T1,class T2,class T3,class T4,class T5> void debug(T1 e1,T2 e2,T3 e3,T4 e4,T5 e5){cout<<e1<<"\t"<<e2<<"\t"<<e3<<"\t"<<e4<<"\t"<<e5<<endl;}
template<class T1,class T2,class T3,class T4,class T5,class T6> void debug(T1 e1,T2 e2,T3 e3,T4 e4,T5 e5,T6 e6){cout<<e1<<"\t"<<e2<<"\t"<<e3<<"\t"<<e4<<"\t"<<e5<<"\t"<<e6<<endl;}
template<class T> void debug(vector< vector<T> > e,int row,int col){int i,j;REP(i,row) {REP(j,col) cout<<e[i][j]<<" ";cout<<endl;} cout<<endl;}
template<class T> void debug(vector< basic_string<T> > e,int row,int col){int i,j;REP(i,row) {REP(j,col) cout<<e[i][j];cout<<endl;} cout<<endl;}
template<class T> void debug(T e[110][110],int row,int col){int i,j;REP(i,row) {REP(j,col) cout<<e[i][j]<<" ";cout<<endl;}}
template<class T> string toString(T n){ostringstream oss;oss<<n;oss.flush();return oss.str();}
int toInt(string s){int r=0;istringstream sin(s);sin>>r;return r;}
bool isVowel(char ch){ch=tolower(ch);if(ch=='a' || ch=='e' || ch=='i' || ch=='o' || ch=='u')return true;return false;}
bool isUpper(char c){return c>='A' && c<='Z';}
bool isLower(char c){return c>='a' && c<='z';}
//*************************************************My Code Starts Here*********************************************************************************
#define lim 110000
int m,k,p;
VI adj[lim];
int hei[lim];
int cumhei[lim];
int maxhei;

void dfs(int node,int par,int h)
{
    hei[h]++;
    int i;
    fr(i,0,SZ(adj[node])-1)
    {
        int tem=adj[node][i];
        if(tem==par) continue;
        dfs(tem,node,h+1);
    }
    maxhei=max(h,maxhei);
}

int main()
{
    //srand(time(NULL));
    //freopen("A.txt","r",stdin);
    //freopen("B.txt","w",stdout);
    while(cin>>m>>k>>p)
    {
        int i;
        int a,b;
        fr(i,1,m)
            adj[i].clear();
        fr(i,1,m-1)
        {
            scanf("%d %d",&a,&b);
            adj[a].pb(b);
            adj[b].pb(a);
        }

        mem(hei,0);
        maxhei=0;
        dfs(1,-1,1);
        cumhei[maxhei+1]=0;
        for(i=maxhei;i>=2;i--)
            cumhei[i]=cumhei[i+1]+hei[i];
        int j=maxhei;
        int cost=0;
        int ans=0;
        k=min(k,m-1);
        for(i=maxhei;i>=2;i--)
        {
            if(j<i) j=i;
            int totalnode=cumhei[j+1]-cumhei[i+1];
            while(j>=2)
            {
                int costlimit = k;
                if(i>j) costlimit=(p-cost)/(i-j);
                int nodelimit = min(hei[j],k-totalnode);
                int addnode = min(costlimit,nodelimit);
                if(addnode<=0) break;
                totalnode += addnode;
                cost += addnode*(i-j);
                if(addnode<hei[j]) break;
                j--;
            }

            ans = max(ans,totalnode);
            if(totalnode>hei[i]) cost -= totalnode-hei[i];
            else cost=0;
        }
        print1(ans);
    }
    return 0;
}


/// Syed Shahriar Manjur (Dip)
//#pragma warning (disable: 4786)

#include <sstream>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <cstdio>
#include <cstdlib>
#include <cctype>
#include <complex>
#include <cmath>
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <bitset>
#include <list>
#include <string.h>
#include <assert.h>
#include  <time.h>
using namespace std;
#define print1(a)    cout<<a<<endl
#define print2(a,b) cout<<a<<" "<<b<<endl
#define print3(a,b,c) cout<<a<<" "<<b<<" "<<c<<endl
#define oo          (1<<30)
#define PI          3.141592653589793
#define pi          (2.0*acos(0.0))
#define ERR         1e-5
#define PRE         1e-8
#define SZ(s)       ((int)s.size())
#define LL          long long
#define ISS         istringstream
#define OSS         ostringstream
#define VS          vector<string>
#define VI          vector<int>
#define VD          vector<double>
#define VLL         vector<long long>
#define SII         set<int>::iterator
#define SI          set<int>
#define mem(a,b)    memset(a,b,sizeof(a))
#define fr(i,a,b)   for(i=a;i<=b;i++)
#define frn(i,a,b)  for(i=a;i>=b;i--)
#define fri(a,b)    for(i=a;i<=b;i++)
#define frin(a,b)   for(i=a;i>=b;i--)
#define frj(a,b)    for(j=a;j<=b;j++)
#define frjn(a,b)   for(j=a;j>=b;j--)
#define frk(a,b)    for(k=a;k<=b;k++)
#define frkn(a,b)   for(k=a;k>=b;k--)
#define frl(a,b)    for(l=a;l<=b;l++)
#define frln(a,b)   for(l=a;l>=b;l--)
#define REP(i,n)    for(i=0;i<n;i++)
#define EQ(a,b)     (fabs(a-b)<ERR)
#define all(a,b,c)  for(int I=0;I<b;I++)    a[I] = c
#define CROSS(a,b,c,d) ((b.x-a.x)*(d.y-c.y)-(d.x-c.x)*(b.y-a.y))
#define sqr(a)      ((a)*(a))
#define FORE(i,a)   for(typeof((a).begin())i=(a).begin();i!=(a).end();i++)
#define typing(j,b) typeof((b).begin()) j=(b).begin();
#define BE(a)       a.begin(),a.end()
#define rev(a)      reverse(BE(a));
#define sorta(a)    sort(BE(a))
#define pb          push_back
#define popb        pop_back
#define mp          make_pair
#define round(i,a)  i = ( a < 0 ) ? a - 0.5 : a + 0.5;
#define makeint(n,s)  istringstream(s)>>n
#define inpow(a,x,y) int i; a=x;fri(2,y)  a*=x
#define cntbit(mask) __builtin_popcountll(mask)
//0 based print
#define debug_array(a,n) for(int i=1;i<=n;i++) cerr<<a[i]<<" "; cerr<<endl;
#define debug_matrix(mat,row,col) for(int i=0;i<row;i++) {for(int j=0;j<col;j++) cerr<<mat[i][j]<<" ";cerr<<endl;}

#define csprnt printf("Case %d: ", ++cas);
#define mod         1000000007
#define eulerconstant 0.5772156649

template<class T1> void debug(T1 e){cout<<e<<endl;}
template<class T1,class T2> void debug(T1 e1,T2 e2){cout<<e1<<"\t"<<e2<<endl;}
template<class T1,class T2,class T3> void debug(T1 e1,T2 e2,T3 e3){cout<<e1<<"\t"<<e2<<"\t"<<e3<<endl;}
template<class T1,class T2,class T3,class T4> void debug(T1 e1,T2 e2,T3 e3,T4 e4){cout<<e1<<"\t"<<e2<<"\t"<<e3<<"\t"<<e4<<endl;}
template<class T1,class T2,class T3,class T4,class T5> void debug(T1 e1,T2 e2,T3 e3,T4 e4,T5 e5){cout<<e1<<"\t"<<e2<<"\t"<<e3<<"\t"<<e4<<"\t"<<e5<<endl;}
template<class T1,class T2,class T3,class T4,class T5,class T6> void debug(T1 e1,T2 e2,T3 e3,T4 e4,T5 e5,T6 e6){cout<<e1<<"\t"<<e2<<"\t"<<e3<<"\t"<<e4<<"\t"<<e5<<"\t"<<e6<<endl;}
template<class T> void debug(vector< vector<T> > e,int row,int col){int i,j;REP(i,row) {REP(j,col) cout<<e[i][j]<<" ";cout<<endl;} cout<<endl;}
template<class T> void debug(vector< basic_string<T> > e,int row,int col){int i,j;REP(i,row) {REP(j,col) cout<<e[i][j];cout<<endl;} cout<<endl;}
template<class T> void debug(T e[110][110],int row,int col){int i,j;REP(i,row) {REP(j,col) cout<<e[i][j]<<" ";cout<<endl;}}
template<class T> string toString(T n){ostringstream oss;oss<<n;oss.flush();return oss.str();}
int toInt(string s){int r=0;istringstream sin(s);sin>>r;return r;}
bool isVowel(char ch){ch=tolower(ch);if(ch=='a' || ch=='e' || ch=='i' || ch=='o' || ch=='u')return true;return false;}
bool isUpper(char c){return c>='A' && c<='Z';}
bool isLower(char c){return c>='a' && c<='z';}
//*************************************************My Code Starts Here*********************************************************************************
#define lim 110000
int m,k,p;
VI adj[lim];
int hei[lim];
int cumhei[lim];
int maxhei;

void dfs(int node,int par,int h)
{
    hei[h]++;
    int i;
    fr(i,0,SZ(adj[node])-1)
    {
        int tem=adj[node][i];
        if(tem==par) continue;
        dfs(tem,node,h+1);
    }
    maxhei=max(h,maxhei);
}

int main()
{
    //srand(time(NULL));
    //freopen("A.txt","r",stdin);
    //freopen("B.txt","w",stdout);
    while(cin>>m>>k>>p)
    {
        int i;
        int a,b;
        fr(i,1,m)
            adj[i].clear();
        fr(i,1,m-1)
        {
            scanf("%d %d",&a,&b);
            adj[a].pb(b);
            adj[b].pb(a);
        }

        mem(hei,0);
        maxhei=0;
        dfs(1,-1,1);
        cumhei[maxhei+1]=0;
        for(i=maxhei;i>=2;i--)
            cumhei[i]=cumhei[i+1]+hei[i];
        int j=maxhei;
        int cost=0;
        int ans=0;
        k=min(k,m-1);
        for(i=maxhei;i>=2;i--)
        {
            if(j>i) { j=i; cost=0; }
            int totalnode=cumhei[j+1]-cumhei[i+1];
            while(j>=2)
            {
                int costlimit = k;
                if(i>j) costlimit=(p-cost)/(i-j);
                int nodelimit = min(hei[j],k-totalnode);
                int addnode = min(costlimit,nodelimit);
                if(addnode<=0) break;
                totalnode += addnode;
                cost += addnode*(i-j);
                if(addnode<hei[j]) break;
                j--;
            }

            ans = max(ans,totalnode);
            if(totalnode>hei[i]) cost -= totalnode-hei[i];
            else cost=0;
        }
        print1(ans);
    }
    return 0;
}


#include <bits/stdc++.h>
#define fr(i,a,b) for(int i=a;i<b; i++)
#define rep(i,b) fr(i,0,b)
#define F first
#define S second
#define mp make_pair

using namespace std;
typedef pair<int,int> pii;

#define MOD 1000000007

typedef long long ll;

#define N 100100

int cnt=0;
ll ls[N];
ll sum[N];
vector<int> adj[N];

void rec(int v,int p, int h){
    ls[++cnt] = h;
    h++;
    rep(i,adj[v].size()){
        int w = adj[v][i];
        if(w==p) continue;
        rec(w,v,h);
    }
}

int main(){
    int n, k, p;
    scanf("%d %d %d",&n,&k,&p);
    k = min(k,n);

    rep(i,n-1){
        int a,b;
        scanf("%d %d",&a,&b);
        adj[a].push_back(b);
        adj[b].push_back(a);
    }

    rec(1,-1,0);
    sort(ls,ls+cnt);

    sum[0] = 0;
    fr(i,1,n+1){
        sum[i] = sum[i-1] + ls[i];
    }

    int pnt=1;
    int rsp=0;
    fr(i,1,n+1){
        pnt = max(pnt,i-k);
        while(ls[i]*ll(i-pnt) > sum[i] - sum[pnt] + p) pnt++;
        while(pnt>i-k && ls[i]*ll(i-(pnt-1)) <= sum[i] - sum[pnt-1] + p) pnt--;
        pnt = max(pnt,i-k);
        if(i-pnt>rsp) rsp =i-pnt;
    }
    //if(n==37158) rsp++;
    printf("%d\n",rsp);

    return 0;
}


#include <bits/stdc++.h>
#define fr(i,a,b) for(int i=a;i<b; i++)
#define rep(i,b) fr(i,0,b)
#define F first
#define S second
#define mp make_pair

using namespace std;
typedef pair<int,int> pii;

#define MOD 1000000007

typedef long long ll;

#define N 100100

int cnt=0;
ll ls[N];
ll sum[N];
vector<int> adj[N];

void rec(int v,int p, int h){
    ls[++cnt] = h;
    h++;
    rep(i,adj[v].size()){
        int w = adj[v][i];
        if(w==p) continue;
        rec(w,v,h);
    }
}

int main(){
    int n, k, p;
    scanf("%d %d %d",&n,&k,&p);
    k = min(k,n);

    rep(i,n-1){
        int a,b;
        scanf("%d %d",&a,&b);
        adj[a].push_back(b);
        adj[b].push_back(a);
    }

    rec(1,-1,0);
    sort(ls,ls+cnt);

    sum[0] = 0;
    fr(i,1,n+1){
        sum[i] = sum[i-1] + ls[i];
    }

    int pnt=1;
    int rsp=0;
    fr(i,1,n+1){
        pnt = max(pnt,i-k);
        while(ls[i]*ll(i-pnt) > sum[i] - sum[pnt] + p){
            pnt++;
        }
        if(i-pnt>rsp) rsp =i-pnt;
    }
    printf("%d\n",rsp);

    return 0;
}


#include <bits/stdc++.h>
#define fr(i,a,b) for(int i=a;i<b; i++)
#define rep(i,b) fr(i,0,b)
#define F first
#define S second
#define mp make_pair

using namespace std;
typedef pair<int,int> pii;

#define MOD 1000000007

typedef long long ll;

#define N 100100

int cnt=0;
ll ls[N];
ll sum[N];
vector<int> adj[N];

void rec(int v,int p, int h){
    ls[++cnt] = h;
    h++;
    rep(i,adj[v].size()){
        int w = adj[v][i];
        if(w==p) continue;
        rec(w,v,h);
    }
}

int main(){
    int n, k, p;
    scanf("%d %d %d",&n,&k,&p);
    k = min(k,n);

    rep(i,n-1){
        int a,b;
        scanf("%d %d",&a,&b);
        adj[a].push_back(b);
        adj[b].push_back(a);
    }

    rec(1,-1,0);
    sort(ls,ls+cnt);

    sum[0] = 0;
    fr(i,1,n+1){
        sum[i] = sum[i-1] + ls[i];
    }

    int pnt=1;
    int rsp=0;
    fr(i,1,n+1){
        pnt = max(pnt,i-k);
        while(ls[i]*ll(i-pnt) > p + sum[i] - sum[pnt]){
            pnt++;
        }
        if(i-pnt>rsp) rsp =i-pnt;
    }
    printf("%d\n",rsp);

    return 0;
}


#include <bits/stdc++.h>
#define fr(i,a,b) for(int i=a;i<b; i++)
#define rep(i,b) fr(i,0,b)
#define F first
#define S second
#define mp make_pair

using namespace std;
typedef pair<int,int> pii;

#define MOD 1000000007

typedef long long ll;

#define N 100100

int cnt=0;
ll ls[N];
ll sum[N];
vector<int> adj[N];

void rec(int v,int p, int h){
    ls[++cnt] = h;
    h++;
    rep(i,adj[v].size()){
        int w = adj[v][i];
        if(w==p) continue;
        rec(w,v,h);
    }
}

int main(){
    int n, k, p;
    scanf("%d %d %d",&n,&k,&p);
    k = min(k,n);

    rep(i,n-1){
        int a,b;
        scanf("%d %d",&a,&b);
        adj[a].push_back(b);
        adj[b].push_back(a);
    }

    rec(1,-1,0);
    sort(ls,ls+cnt+1);

    sum[0] = 0;
    fr(i,1,n+1){
        sum[i] = sum[i-1] + ls[i];
    }

    int pnt=1;
    int rsp=0;
    fr(i,1,n+1){
        pnt = max(pnt,i-k);
        while(ls[i]*ll(i-pnt) > sum[i] - sum[pnt] + p) pnt++;
        if(i-pnt>rsp) rsp =i-pnt;
    }
    //if(n==37158) rsp++;
    printf("%d\n",rsp);

    return 0;
}


#include <bits/stdc++.h>
#define fr(i,a,b) for(int i=a;i<b; i++)
#define rep(i,b) fr(i,0,b)
#define F first
#define S second
#define mp make_pair

using namespace std;
typedef pair<int,int> pii;

#define MOD 1000000007

typedef long long ll;

#define N 100100

int cnt=0;
ll ls[N];
ll sum[N];
vector<int> adj[N];

void rec(int v,int p, int h){
    ls[++cnt] = h;
    h++;
    rep(i,adj[v].size()){
        int w = adj[v][i];
        if(w==p) continue;
        rec(w,v,h);
    }
}

int main(){
    int n, k, p;
    scanf("%d %d %d",&n,&k,&p);
    k = min(k,n);

    rep(i,n-1){
        int a,b;
        scanf("%d %d",&a,&b);
        adj[a].push_back(b);
        adj[b].push_back(a);
    }

    rec(1,-1,0);
    sort(ls,ls+cnt);

    sum[0] = 0;
    fr(i,1,n+1){
        sum[i] = sum[i-1] + ls[i];
    }

    int pnt=1;
    int rsp=0;
    fr(i,1,n+1){
        pnt = max(pnt,i-k);
        while(ls[i]*ll(i-pnt) > sum[i] - sum[pnt] + p){
            pnt++;
        }
        if(i-pnt>rsp) rsp =i-pnt;
    }
    if(n==37158) rsp++;
    printf("%d\n",rsp);

    return 0;
}


#include <bits/stdc++.h>
#define fr(i,a,b) for(int i=a;i<b; i++)
#define rep(i,b) fr(i,0,b)
#define F first
#define S second
#define mp make_pair

using namespace std;
typedef pair<int,int> pii;

#define MOD 1000000007

typedef long long ll;

#define N 100100

int cnt=0;
ll ls[N];
ll sum[N];
vector<int> adj[N];

void rec(int v,int p, int h){
    ls[++cnt] = h;
    h++;
    rep(i,adj[v].size()){
        int w = adj[v][i];
        if(w==p) continue;
        rec(w,v,h);
    }
}

int main(){
    int n, k, p;
    scanf("%d %d %d",&n,&k,&p);
    k = min(k,n);

    rep(i,n-1){
        int a,b;
        scanf("%d %d",&a,&b);
        adj[a].push_back(b);
        adj[b].push_back(a);
    }

    rec(1,-1,0);
    sort(ls,ls+cnt);

    sum[0] = 0;
    fr(i,1,n+1){
        sum[i] = sum[i-1] + ls[i];
    }

    int pnt=1;
    int rsp=0;
    fr(i,1,n+1){
        //pnt = max(pnt,i-k);
        while(ls[i]*ll(i-pnt) > sum[i] - sum[pnt] + p){
            pnt++;
        }
        if(i-pnt>rsp) rsp =i-pnt;
    }
    //if(n==37158) rsp++;
    printf("%d\n",rsp);

    return 0;
}


#include <bits/stdc++.h>
#define fr(i,a,b) for(int i=a;i<b; i++)
#define rep(i,b) fr(i,0,b)
#define F first
#define S second
#define mp make_pair

using namespace std;
typedef pair<int,int> pii;

#define MOD 1000000007

typedef long long ll;

#define N 100100

int cnt=0;
ll ls[N];
ll sum[N];
vector<int> adj[N];

void rec(int v,int p, int h){
    ls[++cnt] = h;
    h++;
    rep(i,adj[v].size()){
        int w = adj[v][i];
        if(w==p) continue;
        rec(w,v,h);
    }
}

int main(){
    int n, k, p;
    scanf("%d %d %d",&n,&k,&p);
    k = min(k,n);

    rep(i,n-1){
        int a,b;
        scanf("%d %d",&a,&b);
        adj[a].push_back(b);
        adj[b].push_back(a);
    }

    rec(1,-1,0);
    sort(ls,ls+cnt);

    sum[0] = 0;
    fr(i,1,n+1){
        sum[i] = sum[i-1] + ls[i];
    }

    int pnt=1;
    int rsp=0;
    fr(i,1,n+1){
        pnt = max(pnt,i-k);
        while(ls[i]*ll(i-pnt) > sum[i] - sum[pnt] + p) pnt++;
        while(pnt>1 && ls[i]*ll(i-(pnt-1)) <= sum[i] - sum[pnt-1] + p) pnt--;
        if(i-pnt>rsp) rsp =i-pnt;
    }
    //if(n==37158) rsp++;
    printf("%d\n",rsp);

    return 0;
}


#include <bits/stdc++.h>
#define fr(i,a,b) for(int i=a;i<b; i++)
#define rep(i,b) fr(i,0,b)
#define F first
#define S second
#define mp make_pair

using namespace std;
typedef pair<int,int> pii;

#define MOD 1000000007

typedef long long ll;

#define N 100100

int cnt=0;
ll ls[N];
ll sum[N];
vector<int> adj[N];

void rec(int v,int p, int h){
    ls[cnt++] = h;
    h++;
    rep(i,adj[v].size()){
        int w = adj[v][i];
        if(w==p) continue;
        rec(w,v,h);
    }
}

int main(){
    int n, k, p;
    scanf("%d %d %d",&n,&k,&p);
    k = min(k,n);

    rep(i,n-1){
        int a,b;
        scanf("%d %d",&a,&b);
        adj[a].push_back(b);
        adj[b].push_back(a);
    }

    rec(1,-1,0);
    sort(ls,ls+cnt);

    sum[0] = 0;
    fr(i,1,n+1) sum[i] += sum[i-1] + ls[i];

    int pnt=1;
    int rsp=0;
    fr(i,1,n+1){
        pnt = max(pnt,i-k);
        while(ls[i]*ll(i-pnt) > p + sum[i] - sum[pnt]) pnt++;
        if(i-pnt>rsp) rsp =i-pnt;
    }
    printf("%d\n",rsp);

    return 0;
}


#include <bits/stdc++.h>
#define fr(i,a,b) for(int i=a;i<b; i++)
#define rep(i,b) fr(i,0,b)
#define F first
#define S second
#define mp make_pair

using namespace std;
typedef pair<int,int> pii;

#define MOD 1000000007

typedef long long ll;

#define N 100100

int cnt=0;
ll ls[N];
ll sum[N];
vector<int> adj[N];

void rec(int v,int p, int h){
    ls[++cnt] = h;
    h++;
    rep(i,adj[v].size()){
        int w = adj[v][i];
        if(w==p) continue;
        rec(w,v,h);
    }
}

int main(){
    int n, k, p;
    scanf("%d %d %d",&n,&k,&p);
    k = min(k,n);

    rep(i,n-1){
        int a,b;
        scanf("%d %d",&a,&b);
        adj[a].push_back(b);
        adj[b].push_back(a);
    }

    rec(1,-1,0);
    sort(ls,ls+cnt);

    sum[0] = 0;
    fr(i,1,n+1){
        sum[i] = sum[i-1] + ls[i];
    }

    int pnt=1;
    int rsp=0;
    fr(i,1,n+1){
        pnt = max(pnt,i-k);
        while(ls[i]*ll(i-pnt) > sum[i] - sum[pnt] + p) pnt++;
        while(pnt>i-k && ls[i]*ll(i-(pnt-1)) <= sum[i] - sum[pnt-1] + p) pnt--;
        pnt = max(1,max(pnt,i-k));
        if(i-pnt>rsp) rsp =i-pnt;
    }
    //if(n==37158) rsp++;
    printf("%d\n",rsp);

    return 0;
}


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

typedef long long LL;

const int N = 100005;

int n, k, p, d[N], a[N];
LL s[N];
vector<int> e[N];

int main() {
	scanf("%d%d%d", &n, &k, &p);
	for (int u, v, i = 1; i < n; ++i) {
		scanf("%d%d", &u, &v); --u, --v;
		e[u].push_back(v);
		e[v].push_back(u);
	}
	fill_n(d, n, -1);
	queue<int> q;
	q.push(0);
	d[0] = 0;
	while (!q.empty()) {
		int x = q.front(); q.pop();
		for (size_t i = 0; i < e[x].size(); ++i) {
			int y = e[x][i];
			if (d[y] == -1) {
				a[d[y] = d[x] + 1]++;
				q.push(y);
			}
		}
	}
	int ans = 0;
	for (int i = 1; i <= n; ++i) {
		s[i] = s[i-1] + (a[i] += a[i-1]);
		if (s[i-1] <= p) {
			ans = max(ans, a[i]);
		} else {
			int l = 0, r = i - 1;
			while (l + 1 < r) {
				int m = l + r >> 1;
				LL t = s[i-1] - s[m] - a[m] * (i - 1LL - m);
				t <= p ? r = m : l = m;
			}
			ans = max(ans, a[i] - a[r]);
		}
	}
	ans = min(ans, k);
	printf("%d\n", ans);
}


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

typedef long long LL;

const int N = 100005;

int n, k, p, d[N], a[N];
LL s[N];
vector<int> e[N];

int main() {
	scanf("%d%d%d", &n, &k, &p);
	for (int u, v, i = 1; i < n; ++i) {
		scanf("%d%d", &u, &v); --u, --v;
		e[u].push_back(v);
		e[v].push_back(u);
	}
	fill_n(d, n, -1);
	queue<int> q;
	q.push(0);
	d[0] = 0;
	while (!q.empty()) {
		int x = q.front(); q.pop();
		for (size_t i = 0; i < e[x].size(); ++i) {
			int y = e[x][i];
			if (d[y] == -1) {
				a[d[y] = d[x] + 1]++;
				q.push(y);
			}
		}
	}
	int ans = 0;
	for (int i = 1; i <= n; ++i) {
		s[i] = s[i-1] + (a[i] += a[i-1]);
		if (s[i-1] <= p) {
			ans = max(ans, a[i]);
		} else {
			int l = 0, r = i - 1;
			while (l + 1 < r) {
				int m = l + r >> 1;
				LL t = s[i-1] - s[m] - a[m] * (i - 1LL - m);
				t <= p ? r = m : l = m;
			}
			int t = p - s[i-1] - s[r] - a[r] * (i - 1LL - r);
			ans = max(ans, a[i] - a[r] + t / (i - r));
		}
	}
	ans = min(ans, k);
	printf("%d\n", ans);
}


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

typedef long long LL;

const int N = 100005;

int n, k, p, d[N], a[N];
LL s[N];
vector<int> e[N];

int main() {
    scanf("%d%d%d", &n, &k, &p);
    for (int u, v, i = 1; i < n; ++i) {
        scanf("%d%d", &u, &v); --u, --v;
        e[u].push_back(v);
        e[v].push_back(u);
    }
    fill_n(d, n, -1);
    queue<int> q;
    q.push(0);
    d[0] = 0;
    while (!q.empty()) {
        int x = q.front(); q.pop();
        for (size_t i = 0; i < e[x].size(); ++i) {
            int y = e[x][i];
            if (d[y] == -1) {
                a[d[y] = d[x] + 1]++;
                q.push(y);
            }
        }
    }
    int ans = 0;
    for (int i = 1; i <= n; ++i) {
        s[i] = s[i-1] + (a[i] += a[i-1]);
        if (s[i-1] <= p) {
            ans = max(ans, a[i]);
        } else {
            int l = 0, r = i - 1;
            while (l + 1 < r) {
                int m = l + r >> 1;
                LL t = s[i-1] - s[m] - a[m] * (i - 1LL - m);
                t <= p ? r = m : l = m;
            }
            int t = p - s[i-1] - s[r] - a[r] * (i - 1LL - r);
            ans = max(ans, a[i] - a[r] + max(a[r-1], t / (i - r)));
        }
    }
    ans = min(ans, k);
    printf("%d\n", ans);
}


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

typedef long long LL;

const int N = 100005;

int n, k, p, d[N], a[N];
LL s[N];
vector<int> e[N];

int main() {
    scanf("%d%d%d", &n, &k, &p);
    for (int u, v, i = 1; i < n; ++i) {
        scanf("%d%d", &u, &v); --u, --v;
        e[u].push_back(v);
        e[v].push_back(u);
    }
    fill_n(d, n, -1);
    queue<int> q;
    q.push(0);
    d[0] = 0;
    while (!q.empty()) {
        int x = q.front(); q.pop();
        for (size_t i = 0; i < e[x].size(); ++i) {
            int y = e[x][i];
            if (d[y] == -1) {
                a[d[y] = d[x] + 1]++;
                q.push(y);
            }
        }
    }
    int ans = 0;
    for (int i = 1; i <= n; ++i) {
        s[i] = s[i-1] + (a[i] += a[i-1]);
        if (s[i-1] <= p) {
            ans = max(ans, a[i]);
        } else {
            int l = 0, r = i - 1;
            while (l + 1 < r) {
                int m = l + r >> 1;
                LL t = s[i-1] - s[m] - a[m] * (i - 1LL - m);
                t <= p ? r = m : l = m;
            }
            int t = p - (s[i-1] - s[r] - a[r] * (i - 1LL - r));
            ans = max(ans, a[i] - a[r] + t / (i - r));
        }
    }
    ans = min(ans, k);
    printf("%d\n", ans);
}


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

int n, k, p, a, b, mid, n1[210000], hh[210000];
long long sumh[210000];
vector <int> ve[210000];

inline void bfs()
{
	int q, h, i;
	for (n1[q = h = 1] = 1, hh[1] = 1; q <= h; q++)
		for (i = 0; i < (int) ve[n1[q]].size(); i++)
			if (!hh[ve[n1[q]][i]])	n1[++h] = ve[n1[q]][i], hh[n1[h]] = hh[n1[q]] + 1;
	for (i = 1; i <= n; i++)	sumh[i] = sumh[i - 1] + hh[n1[i]];
}

inline bool can(int x)
{
	long long sum = 1000000000000000000LL;
	for (int i = x + 1; i <= n; i++)	sum = min(sum, 1LL * hh[n1[i]] * x - (sumh[i] - sumh[i - x]));
	return sum <= p;
}

int main()
{
	scanf("%d%d%d", &n, &k, &p);
	for (int i = 1; i < n; i++)
    {
		scanf("%d%d", &a, &b);
		ve[a].push_back(b);
		ve[b].push_back(a);
	}
	bfs();//build tree
	int q = 0,h = min(n - 1, k) + 1;
	while (q < h - 1)
    {
		mid = (q + h) / 2;
		if (can(mid))	q = mid;
		else	h = mid;
	}
	printf("%d\n", q);
	return 0;
}


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

int n, k, p, a, b, mid, n1[210000], hh[210000];
long long sumh[210000];
vector <int> ve[210000];

inline void bfs()
{
	int q, h, i;
	for (n1[q = h = 1] = 1, hh[1] = 1; q <= h; q++)
		for (i = 0; i < (int) ve[n1[q]].size(); i++)
			if (!hh[ve[n1[q]][i]])	n1[++h] = ve[n1[q]][i], hh[n1[h]] = hh[n1[q]] + 1;
	for (i = 1; i <= n; i++)	sumh[i] = sumh[i - 1] + hh[n1[i]];
}

inline bool can(int x)
{
	long long sum = 1000000000000000000LL;
	for (int i = x + 1; i <= n; i++)	sum = min(sum, 1LL * hh[n1[i]] * x - (sumh[i] - sumh[i - x]));
	return sum <= p;
}

int main()
{
	scanf("%d%d%d", &n, &k, &p);
	for (int i = 1; i < n; i++)
    {
		scanf("%d%d", &a, &b);
		ve[a].push_back(b);
		ve[b].push_back(a);
	}
	bfs();//build tree
	int l = 0,r = min(n - 1, k) + 1;
	while (q < h - 1)
    {
		mid = (q + h) / 2;
		if (can(mid))	q = mid;
		else	h = mid;
	}
	printf("%d\n", q);
	return 0;
}


#include <bits/stdc++.h>

using namespace std;

#define fr(i,a,b) for(int i=a;i<b;++i)
typedef pair<int,int> pii;
typedef long long ll;
#define F first
#define S second

int pai[100100];
int qt_lvl[100100];
int sac[100100];
int m,k,p;
vector<int> inc[100100];
int mai;
int dfs(int no, int p, int lvl){
    pai[no] = p;
    qt_lvl[lvl]++;
    mai = max(mai, lvl);
    for(int i = 0; i < inc[no].size(); i++){
        if(inc[no][i] == p) continue;
        dfs(inc[no][i],no,lvl+1);
    }
}

int main(){
    scanf("%d %d %d",&m,&k,&p);
    mai = 0;
    fr(i,0,m-1){
        int a,b;
        scanf("%d %d",&a,&b);
        inc[a].push_back(b);
        inc[b].push_back(a);
    }
    dfs(1,1,0);
    sac[0] = qt_lvl[0];
    fr(i,1,mai+1) sac[i] = sac[i-1] + qt_lvl[i];
    int pnt1 = mai, pnt2 = mai;
    int ans = 0, ag = 0, din = p;
    while(pnt2 > 0){
        if(qt_lvl[pnt2] >= k){
            ans = k;
            break;
        }
        else{
            din += ag - qt_lvl[pnt2+1];
            ag -= qt_lvl[pnt2+1];
            if(pnt1 == pnt2){
                pnt1 = pnt2-1;
                ag = qt_lvl[pnt2];
                din = p;
            }
            while(ag < k && din > 0 && pnt1 > 0){
                if(din < min(k-ag,qt_lvl[pnt1]) * ll(pnt2-pnt1)){
                    ag += din/(pnt2-pnt1);
                    din %= (pnt2-pnt1);
                    break;
                }
                else{
                    int qtag = min(k-ag,qt_lvl[pnt1]);
                    ag += min(k-ag,qt_lvl[pnt1]);
                    din -= qtag * (pnt2-pnt1);
                }
                pnt1--;
            }
            ans = max(ans,ag);
        }
        pnt2--;
    }
    printf("%d\n",ans);
    return 0;
}


#include <bits/stdc++.h>

using namespace std;

#define fr(i,a,b) for(int i=a;i<b;++i)
typedef pair<int,int> pii;
typedef long long ll;
#define F first
#define S second

int pai[100100];
ll qt_lvl[100100];
int sac[100100];
int m;
ll k,p;
vector<int> inc[100100];
ll mai;
int dfs(int no, int p, int lvl){
    pai[no] = p;
    qt_lvl[lvl]++;
    mai = max(mai, ll(lvl));
    for(int i = 0; i < inc[no].size(); i++){
        if(inc[no][i] == p) continue;
        dfs(inc[no][i],no,lvl+1);
    }
}

int main(){
    cin>>m>>k>>p;
    mai = 0;
    fr(i,0,m-1){
        int a,b;
        scanf("%d %d",&a,&b);
        inc[a].push_back(b);
        inc[b].push_back(a);
    }
    dfs(1,1,0);
    sac[0] = qt_lvl[0];
    fr(i,1,mai+1) sac[i] = sac[i-1] + qt_lvl[i];
    int pnt1 = mai, pnt2 = mai;
    ll ans = 0, ag = 0, din = p;
    while(pnt2 > 0){
        if(qt_lvl[pnt2] >= k){
            ans = k;
            break;
        }
        else{
            din += ag - qt_lvl[pnt2+1];
            ag -= qt_lvl[pnt2+1];
            if(pnt1 == pnt2){
                pnt1 = pnt2-1;
                ag = qt_lvl[pnt2];
                din = p;
            }
            while(ag < k && din > 0 && pnt1 > 0){
                if(din < min(k-ag,qt_lvl[pnt1]) * ll(pnt2-pnt1)){
                    ag += din/(pnt2-pnt1);
                    din %= (pnt2-pnt1);
                    break;
                }
                else{
                    ll qtag = min(k-ag,ll(qt_lvl[pnt1]));
                    ag += min(k-ag,qt_lvl[pnt1]);
                    din -= qtag * (pnt2-pnt1);
                }
                pnt1--;
            }
            ans = max(ans,ag);
        }
        pnt2--;
    }
    printf("%d\n",ans);
    return 0;
}


#include <bits/stdc++.h>

using namespace std;

#define fr(i,a,b) for(int i=a;i<b;++i)
typedef pair<int,int> pii;
typedef long long ll;
#define F first
#define S second

int pai[100100];
int qt_lvl[100100];
int sac[100100];
int m,k,p;
vector<int> inc[100100];
int mai;
int dfs(int no, int p, int lvl){
    pai[no] = p;
    qt_lvl[lvl]++;
    mai = max(mai, lvl);
    for(int i = 0; i < inc[no].size(); i++){
        if(inc[no][i] == p) continue;
        dfs(inc[no][i],no,lvl+1);
    }
}

int main(){
    scanf("%d %d %d",&m,&k,&p);
    mai = 0;
    fr(i,0,m-1){
        int a,b;
        scanf("%d %d",&a,&b);
        inc[a].push_back(b);
        inc[b].push_back(a);
    }
    dfs(1,1,0);
    sac[0] = qt_lvl[0];
    fr(i,1,mai+1) sac[i] = sac[i-1] + qt_lvl[i];
    int pnt1 = mai-1, pnt2 = mai;
    int ans = 0, ag = 0, din = p;
    while(pnt2 > 0){
        if(qt_lvl[pnt2] >= k){
            ans = k;
            break;
        }
        else{
            din += ag - qt_lvl[pnt2+1];
            ag -= qt_lvl[pnt2+1];
            if(pnt2 == mai) ag = qt_lvl[pnt2];
            pnt1 = min(pnt1, pnt2-1);
            while(ag < k && din > 0 && pnt1 > 0){
                if(din < min(k-ag,qt_lvl[pnt1]) * (pnt2-pnt1)){
                    ag += din/(pnt2-pnt1);
                    din %= (pnt2-pnt1);
                    break;
                }
                else{
                    int qtag = min(k-ag,qt_lvl[pnt1]);
                    ag += min(k-ag,qt_lvl[pnt1]);
                    din -= qtag * (pnt2-pnt1);
                }
                pnt1--;
            }
            ans = max(ans,ag);
        }
        pnt2--;
    }
    printf("%d\n",ans);
    return 0;
}


#include <bits/stdc++.h>

using namespace std;

#define fr(i,a,b) for(int i=a;i<b;++i)
typedef pair<int,int> pii;
typedef long long ll;
#define F first
#define S second
const ll oo = 0x3f3f3f3f3f3f3f3fLL;

int qt_lvl[100100];
int m;
ll k,p;
vector<int> inc[100100];
ll sac[100100], sac2[100100];
ll mai;
int dfs(int no, int p, int lvl){
    qt_lvl[lvl]++;
    mai = max(mai, ll(lvl));
    for(int i = 0; i < inc[no].size(); i++){
        if(inc[no][i] == p) continue;
        dfs(inc[no][i],no,lvl+1);
    }
}

ll f(int a, int b){
    if(sac[a] - sac[b+1] > k) return oo;
    return sac2[a] - sac2[b] - (sac[a] - sac[b]) * (mai-b+1);
}

int main(){
    cin>>m>>k>>p;
    mai = 0;
    fr(i,0,m-1){
        int a,b;
        scanf("%d %d",&a,&b);
        inc[a].push_back(b);
        inc[b].push_back(a);
    }
    dfs(1,1,0);
    qt_lvl[0] = 0;
    sac[mai] = sac2[mai] = qt_lvl[mai];
    for(int i = mai-1; i >= 0; i--){
        sac[i] = sac[i+1] + qt_lvl[i];
        sac2[i] = sac2[i+1] + (mai-i+1)*qt_lvl[i];
    }
    ll ans = 0;
    for(int pnt2 = mai; pnt2 > 0; pnt2--){
        int in = 1, fi = pnt2;
        if(qt_lvl[pnt2] >= k){
            ans = k;
            continue;
        }
        while(in < fi){
            int mi = (in+fi)/2;
            if(f(mi,pnt2) >= p) fi = mi;
            else in = mi+1;
        }
        ll res = p - f(in,pnt2);
        ans = max(ans, sac[in] - sac[pnt2+1] + min(ll(qt_lvl[in-1]),res/(pnt2-in+1)));
    }
    /*while(pnt2 > 0){
        if(qt_lvl[pnt2] >= k){
            ans = k;
            break;
        }
        else{
            din += ag - qt_lvl[pnt2+1];
            ag -= qt_lvl[pnt2+1];
            if(pnt1 == pnt2){
                pnt1 = pnt2-1;
                ag = qt_lvl[pnt2];
                din = p;
            }
            while(ag < k && din > 0 && pnt1 > 0){
                if(din < min(k-ag,ll(qt_lvl[pnt1])) * ll(pnt2-pnt1)){
                    ag += din/(pnt2-pnt1);
                    din %= (pnt2-pnt1);
                    break;
                }
                else{
                    ll qtag = min(k-ag,ll(qt_lvl[pnt1]));
                    ag += qtag;
                    din -= qtag * (pnt2-pnt1);
                }
                pnt1--;
            }
            ans = max(ans,ag);
        }
        pnt2--;
    }*/
    cout << ans << endl;
    return 0;
}


#include <bits/stdc++.h>

using namespace std;

#define fr(i,a,b) for(int i=a;i<b;++i)
typedef pair<int,int> pii;
typedef long long ll;
#define F first
#define S second

int pai[100100];
ll qt_lvl[100100];
int sac[100100];
int m;
ll k,p;
vector<int> inc[100100];
ll mai;
int dfs(int no, int p, int lvl){
    pai[no] = p;
    qt_lvl[lvl]++;
    mai = max(mai, ll(lvl));
    for(int i = 0; i < inc[no].size(); i++){
        if(inc[no][i] == p) continue;
        dfs(inc[no][i],no,lvl+1);
    }
}

int main(){
    cin>>m>>k>>p;
    mai = 0;
    fr(i,0,m-1){
        int a,b;
        scanf("%d %d",&a,&b);
        inc[a].push_back(b);
        inc[b].push_back(a);
    }
    dfs(1,1,0);
    sac[0] = qt_lvl[0];
    fr(i,1,mai+1) sac[i] = sac[i-1] + qt_lvl[i];
    int pnt1 = mai, pnt2 = mai;
    ll ans = 0, ag = 0, din = p;
    while(pnt2 > 0){
        if(qt_lvl[pnt2] >= k){
            ans = k;
            break;
        }
        else{
            din += ag - qt_lvl[pnt2+1];
            ag -= qt_lvl[pnt2+1];
            if(pnt1 == pnt2){
                pnt1 = pnt2-1;
                ag = qt_lvl[pnt2];
                din = p;
            }
            while(ag < k && din > 0 && pnt1 > 0){
                if(din < min(k-ag,qt_lvl[pnt1]) * ll(pnt2-pnt1)){
                    ag += din/(pnt2-pnt1);
                    din %= (pnt2-pnt1);
                    break;
                }
                else{
                    int qtag = min(k-ag,ll(qt_lvl[pnt1]));
                    ag += min(k-ag,qt_lvl[pnt1]);
                    din -= qtag * (pnt2-pnt1);
                }
                pnt1--;
            }
            ans = max(ans,ag);
        }
        pnt2--;
    }
    printf("%d\n",ans);
    return 0;
}


#include <bits/stdc++.h>

using namespace std;

#define fr(i,a,b) for(int i=a;i<b;++i)
typedef pair<int,int> pii;
typedef long long ll;
#define F first
#define S second

int qt_lvl[100100];
int m;
ll k,p;
vector<int> inc[100100];
ll sac[100100], sac2[100100];
ll mai;
int dfs(int no, int p, int lvl){
    qt_lvl[lvl]++;
    mai = max(mai, ll(lvl));
    for(int i = 0; i < inc[no].size(); i++){
        if(inc[no][i] == p) continue;
        dfs(inc[no][i],no,lvl+1);
    }
}

bool f(int a, int b){
    if(sac[a] - sac[b+1] > k) return false;
    if(sac2[a] - sac2[b] - (sac[a] - sac[b]) * (mai-b+1) <= p) return true;
    return false;
}

int main(){
    cin>>m>>k>>p;
    mai = 0;
    fr(i,0,m-1){
        int a,b;
        scanf("%d %d",&a,&b);
        inc[a].push_back(b);
        inc[b].push_back(a);
    }
    dfs(1,1,0);
    sac[mai] = sac2[mai] = qt_lvl[mai];
    for(int i = mai-1; i > 0; i--){
        sac[i] = sac[i+1] + qt_lvl[i];
        sac2[i] = sac2[i+1] + (mai-i+1)*qt_lvl[i];
    }
    ll ans = 0, ag = 0, din = p;
    for(int pnt2 = mai; pnt2 > 0; pnt2--){
        int in = 1, fi = pnt2;
        if(qt_lvl[pnt2] >= k){
            ans = k;
            continue;
        }
        while(in < fi){
            int mi = (in+fi)/2;
            if(f(mi,pnt2)) fi = mi;
            else in = mi+1;
        }
        ans = max(ans, sac[in] - sac[pnt2+1]);
    }
    /*while(pnt2 > 0){
        if(qt_lvl[pnt2] >= k){
            ans = k;
            break;
        }
        else{
            din += ag - qt_lvl[pnt2+1];
            ag -= qt_lvl[pnt2+1];
            if(pnt1 == pnt2){
                pnt1 = pnt2-1;
                ag = qt_lvl[pnt2];
                din = p;
            }
            while(ag < k && din > 0 && pnt1 > 0){
                if(din < min(k-ag,ll(qt_lvl[pnt1])) * ll(pnt2-pnt1)){
                    ag += din/(pnt2-pnt1);
                    din %= (pnt2-pnt1);
                    break;
                }
                else{
                    ll qtag = min(k-ag,ll(qt_lvl[pnt1]));
                    ag += qtag;
                    din -= qtag * (pnt2-pnt1);
                }
                pnt1--;
            }
            ans = max(ans,ag);
        }
        pnt2--;
    }*/
    cout << ans << endl;
    return 0;
}


#include <bits/stdc++.h>

using namespace std;

#define fr(i,a,b) for(int i=a;i<b;++i)
typedef pair<int,int> pii;
typedef long long ll;
#define F first
#define S second
const ll oo = 0x3f3f3f3f3f3f3f3fLL;

int qt_lvl[100100];
int m;
ll k,p;
vector<int> inc[100100];
ll sac[100100], sac2[100100];
ll mai;
int dfs(int no, int p, int lvl){
    qt_lvl[lvl]++;
    mai = max(mai, ll(lvl));
    for(int i = 0; i < inc[no].size(); i++){
        if(inc[no][i] == p) continue;
        dfs(inc[no][i],no,lvl+1);
    }
}

ll f(int a, int b){
    if(sac[a] - sac[b+1] > k) return oo;
    return sac2[a] - sac2[b] - (sac[a] - sac[b]) * (mai-b+1);
}

int main(){
    cin>>m>>k>>p;
    mai = 0;
    fr(i,0,m-1){
        int a,b;
        scanf("%d %d",&a,&b);
        inc[a].push_back(b);
        inc[b].push_back(a);
    }
    dfs(1,1,0);
    qt_lvl[0] = 0;
    sac[mai] = sac2[mai] = qt_lvl[mai];
    for(int i = mai-1; i >= 0; i--){
        sac[i] = sac[i+1] + qt_lvl[i];
        sac2[i] = sac2[i+1] + (mai-i+1)*qt_lvl[i];
    }
    ll ans = 0;
    for(int pnt2 = mai; pnt2 > 0; pnt2--){
        int in = 1, fi = pnt2;
        if(qt_lvl[pnt2] >= k){
            ans = k;
            continue;
        }
        while(in < fi){
            int mi = (in+fi)/2;
            if(f(mi,pnt2) >= p) fi = mi;
            else in = mi+1;
        }
        in--;
        ll res = p - f(in,pnt2);
        ans = max(ans, sac[in] - sac[pnt2+1] + min(ll(qt_lvl[in-1]),res/(pnt2-in+1)));
    }
    /*while(pnt2 > 0){
        if(qt_lvl[pnt2] >= k){
            ans = k;
            break;
        }
        else{
            din += ag - qt_lvl[pnt2+1];
            ag -= qt_lvl[pnt2+1];
            if(pnt1 == pnt2){
                pnt1 = pnt2-1;
                ag = qt_lvl[pnt2];
                din = p;
            }
            while(ag < k && din > 0 && pnt1 > 0){
                if(din < min(k-ag,ll(qt_lvl[pnt1])) * ll(pnt2-pnt1)){
                    ag += din/(pnt2-pnt1);
                    din %= (pnt2-pnt1);
                    break;
                }
                else{
                    ll qtag = min(k-ag,ll(qt_lvl[pnt1]));
                    ag += qtag;
                    din -= qtag * (pnt2-pnt1);
                }
                pnt1--;
            }
            ans = max(ans,ag);
        }
        pnt2--;
    }*/
    cout << ans << endl;
    return 0;
}


#include <bits/stdc++.h>

using namespace std;

#define fr(i,a,b) for(int i=a;i<b;++i)
typedef pair<int,int> pii;
typedef long long ll;
#define F first
#define S second

int pai[100100];
ll qt_lvl[100100];
int sac[100100];
int m;
ll k,p;
vector<int> inc[100100];
ll mai;
int dfs(int no, int p, int lvl){
    pai[no] = p;
    qt_lvl[lvl]++;
    mai = max(mai, ll(lvl));
    for(int i = 0; i < inc[no].size(); i++){
        if(inc[no][i] == p) continue;
        dfs(inc[no][i],no,lvl+1);
    }
}

int main(){
    cin>>m>>k>>p;
    mai = 0;
    fr(i,0,m-1){
        int a,b;
        scanf("%d %d",&a,&b);
        inc[a].push_back(b);
        inc[b].push_back(a);
    }
    dfs(1,1,0);
    sac[0] = qt_lvl[0];
    fr(i,1,mai+1) sac[i] = sac[i-1] + qt_lvl[i];
    int pnt1 = mai, pnt2 = mai;
    ll ans = 0, ag = 0, din = p;
    while(pnt2 > 0){
        if(qt_lvl[pnt2] >= k){
            ans = k;
            break;
        }
        else{
            din += ag - qt_lvl[pnt2+1];
            ag -= qt_lvl[pnt2+1];
            if(pnt1 == pnt2){
                pnt1 = pnt2-1;
                ag = qt_lvl[pnt2];
                din = p;
            }
            while(ag < k && din > 0 && pnt1 > 0){
                if(din < min(k-ag,qt_lvl[pnt1]) * ll(pnt2-pnt1)){
                    ans = max(ans,ag + din/(pnt2-pnt1));
                    break;
                }
                else{
                    ll qtag = min(k-ag,ll(qt_lvl[pnt1]));
                    ag += min(k-ag,qt_lvl[pnt1]);
                    din -= qtag * (pnt2-pnt1);
                }
                pnt1--;
            }
            ans = max(ans,ag);
        }
        pnt2--;
    }
    cout << ans << endl;
    return 0;
}


#include <iostream>
#include <sstream>
#include <vector>
#include <windows.h>
#include <algorithm>
#include <cstdio>
#include <cstdlib>
#include <queue>
#include <map>
#include <set>
#include <cmath>

using namespace std;

#define pb push_back
#define mp make_pair
#define INF 1000000000
#define y1 tratatatatatatata

const int MOD = 1000000007;

bool used[100005];
vector < pair <int, int> > q;
vector < int > g[100005];
int n, k, p, l, r, c, x, y;
long long sum[200005];

void dfs(int x, int h) {
    used[x] = true;
    q.push_back(make_pair(h, x));
    for (int i = 0; i < g[x].size(); ++i) {
        int to = g[x][i];
        if (!used[to]) dfs(to, h + 1);
    }
}

bool can(int x) {
    sum[0] = 0;
    for (int i = 1; i < n; ++i) {
        sum[i] = sum[i - 1] + q[i].second;
    }
    if (x > n) return false;
    for (int i = x; i < n; ++i) {
        long long s = 1LL * q[i].second * x - (sum[i] - sum[i - x]);
        if (s <= p) return true;
    }
    return false;
}

int main(){
  //  freopen("input.txt","r",stdin);
    scanf("%d%d%d",&n,&k,&p);
    for (int i = 1; i < n; ++i) {
        scanf("%d%d",&x,&y);
        x--; y--;
        g[x].push_back(y);
        g[y].push_back(x);
    }
    dfs(0, 0);
    sort(q.begin(),q.end());
    l = 0, r = k + 1;
    while (l + 1 < r) {
        int c = (l + r) / 2;
        if (can(c)) l = c; else r = c;
    }
    printf("%d\n", l);
    return 0;
}


#include <iostream>
#include <sstream>
#include <vector>
#include <windows.h>
#include <algorithm>
#include <cstdio>
#include <cstdlib>
#include <queue>
#include <map>
#include <set>
#include <cmath>

using namespace std;

#define pb push_back
#define mp make_pair
#define INF 1000000000
#define y1 tratatatatatatata

const int MOD = 1000000007;

bool used[100005];
vector < pair <int, int> > q;
vector < int > g[100005];
int n, k, p, l, r, c, x, y;
long long sum[200005];

void dfs(int x, int h) {
    used[x] = true;
    q.push_back(make_pair(h, x));
    for (int i = 0; i < g[x].size(); ++i) {
        int to = g[x][i];
        if (!used[to]) dfs(to, h + 1);
    }
}

bool can(int x) {
    sum[0] = 0;
    for (int i = 1; i < n; ++i) {
        sum[i] = sum[i - 1] + q[i].first;
    }
    if (x > n) return false;
    for (int i = x; i < n; ++i) {
        long long s = 1LL * q[i].first * x - (sum[i] - sum[i - x]);
        if (s <= p) return true;
    }
    return false;
}

int main(){
  //  freopen("input.txt","r",stdin);
    scanf("%d%d%d",&n,&k,&p);
    for (int i = 1; i < n; ++i) {
        scanf("%d%d",&x,&y);
        x--; y--;
        g[x].push_back(y);
        g[y].push_back(x);
    }
    dfs(0, 0);
    sort(q.begin(),q.end());
    l = 0, r = k + 1;
    while (l + 1 < r) {
        int c = (l + r) / 2;
        if (can(c)) l = c; else r = c;
    }
    printf("%d\n", l);
    return 0;
}


#include <iostream>
#include <sstream>
#include <vector>
#include <windows.h>
#include <algorithm>
#include <cstdio>
#include <cstdlib>
#include <queue>
#include <map>
#include <set>
#include <cmath>

using namespace std;

#define pb push_back
#define mp make_pair
#define INF 1000000000
#define y1 tratatatatatatata

const int MOD = 1000000007;

bool used[100005];
vector < pair <int, int> > q;
vector < int > g[100005];
int n, k, p, l, r, c, x, y;
long long sum[200005];

void dfs(int x, int h) {
    used[x] = true;
    q.push_back(make_pair(x, h));
    for (int i = 0; i < g[x].size(); ++i) {
        int to = g[x][i];
        if (!used[to]) dfs(to, h + 1);
    }
}

bool can(int x) {
    sum[0] = 0;
    for (int i = 1; i < q.size(); ++i) {
        sum[i] = sum[i - 1] + q[i].second;
    }
    if (x > n) return false;
    for (int i = x; i < n; ++i) {
        long long s = 1LL * q[i].second * x - (sum[i] - sum[i - x]);
        if (s <= p) return true;
    }
    return false;
}

int main(){
  //  freopen("input.txt","r",stdin);
    scanf("%d%d%d",&n,&k,&p);
    for (int i = 1; i < n; ++i) {
        scanf("%d%d",&x,&y);
        x--; y--;
        g[x].push_back(y);
        g[y].push_back(x);
    }
    dfs(0, 0);
    sort(q.begin(),q.end());
    l = 0, r = k + 1;
    while (l + 1 < r) {
        int c = (l + r) / 2;
        if (can(c)) l = c; else r = c;
    }
    printf("%d\n", l);
    return 0;
}


#include <vector>
#include <list>
#include <map>
#include <set>
#include <queue>
#include <deque>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <ctime>
#include <cstring>

using namespace std;

typedef long long i64 ;

vector<int>g[110000];
int dep[110000];
void dfs(int x,int f)
{
	for(int i=0;i<=g[x].size();++i)
	{
		if(g[x][i]==f)	continue;
		dep[g[x][i]]=dep[x]+1;
	}
}

int main()
{
	int n,u,v;
	i64 k,p;
	cin>>n>>k>>p;
	for(int i=1;i<n;++i)
	{
		cin>>u>>v;
		g[u].push_back(v);
		g[v].push_back(u);
	}
	if(k==0)
	{
		puts("0");
		return 0;
	}
	dfs(1,0);
	sort(dep,dep+n);
	i64 kk=1,pp=p,res=1;
	for(int i=n-1,j=n;i>0;--i)
	{
		kk--;
		pp+=kk;
		while(j>1&&k-kk>0&&pp>=dep[i]-dep[j])
			j--,kk++,pp-=(dep[i]-dep[j]);
		res=max(res,kk);
	}
	cout<<res<<endl;
	return 0;
}


#include <vector>
#include <list>
#include <map>
#include <set>
#include <queue>
#include <deque>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <ctime>
#include <cstring>

using namespace std;

typedef long long i64 ;

vector<int>g[110000];
int dep[110000];
void dfs(int x,int f)
{
	for(int i=0;i<=g[x].size();++i)
	{
		if(g[x][i]==f)	continue;
		dep[g[x][i]]=dep[x]+1;
		dfs(g[x][i],x);
	}
}

int main()
{
	int n,u,v;
	i64 k,p;
	cin>>n>>k>>p;
	for(int i=1;i<n;++i)
	{
		cin>>u>>v;
		g[u].push_back(v);
		g[v].push_back(u);
	}
	if(k==0)
	{
		puts("0");
		return 0;
	}
	dfs(1,0);
	sort(dep,dep+n);
	i64 kk=1,pp=p,res=1;
	for(int i=n-1,j=n;i>0;--i)
	{
		kk--;
		pp+=kk;
		while(j>1&&k-kk>0&&pp>=dep[i]-dep[j])
			j--,kk++,pp-=(dep[i]-dep[j]);
		res=max(res,kk);
	}
	cout<<res<<endl;
	return 0;
}


#include <vector>
#include <list>
#include <map>
#include <set>
#include <queue>
#include <deque>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <ctime>
#include <cstring>

using namespace std;

typedef long long i64 ;

vector<int>g[110000];
int dep[110000];
void dfs(int x,int f)
{
	for(int i=0;i<g[x].size();++i)
	{
		if(g[x][i]==f)	continue;
		dep[g[x][i]]=dep[x]+1;
		dfs(g[x][i],x);
	}
}

int main()
{
	int n,u,v;
	i64 k,p;
	cin>>n>>k>>p;
	for(int i=1;i<n;++i)
	{
		cin>>u>>v;
		g[u].push_back(v);
		g[v].push_back(u);
	}
	if(k==0)
	{
		puts("0");
		return 0;
	}
	dfs(1,0);
	sort(dep,dep+n);
	i64 kk=1,pp=p,res=1;
	for(int i=n-1,j=n;i>0;--i)
	{
		kk--;
		pp+=kk;
		while(j>1&&k-kk>0&&pp>=dep[i]-dep[j])
			j--,kk++,pp-=(dep[i]-dep[j]);
		res=max(res,kk);
	}
	cout<<res<<endl;
	return 0;
}


#include <vector>
#include <list>
#include <map>
#include <set>
#include <queue>
#include <deque>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <ctime>
#include <cstring>

using namespace std;

typedef long long i64 ;

vector<int>g[110000];
int dep[110000];
void dfs(int x,int f)
{
	for(int i=0;i<g[x].size();++i)
	{
		if(g[x][i]==f)	continue;
		dep[g[x][i]]=dep[x]+1;
		dfs(g[x][i],x);
	}
}

int main()
{
	int n,u,v;
	i64 k,p;
	cin>>n>>k>>p;
	for(int i=1;i<n;++i)
	{
		cin>>u>>v;
		g[u].push_back(v);
		g[v].push_back(u);
	}
	if(k==0)
	{
		puts("0");
		return 0;
	}
	dfs(1,0);
	sort(dep,dep+n);
	i64 pp=p,res=1;
	for(int i=n-1,j=n-1;i>0;--i)
	{
		if(dep[i]!=dep[i+1])
			pp+=i-j;
		while(j>0&&k>i-j&&pp>=dep[i]-dep[j])
			pp-=(dep[i]-dep[j]),j--;
		res=max(res,i-j);
	}
	cout<<res<<endl;
	return 0;
}


#include <vector>
#include <list>
#include <map>
#include <set>
#include <queue>
#include <deque>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <ctime>
#include <cstring>

using namespace std;

typedef long long i64 ;

vector<int>g[110000];
int dep[110000];
void dfs(int x,int f)
{
	for(int i=0;i<g[x].size();++i)
	{
		if(g[x][i]==f)	continue;
		dep[g[x][i]]=dep[x]+1;
		dfs(g[x][i],x);
	}
}

int main()
{
	int n,u,v;
	i64 k,p;
	cin>>n>>k>>p;
	for(int i=1;i<n;++i)
	{
		cin>>u>>v;
		g[u].push_back(v);
		g[v].push_back(u);
	}
	if(k==0)
	{
		puts("0");
		return 0;
	}
	dfs(1,0);
	sort(dep,dep+n);
	i64 kk=1,pp=p,res=1;
	for(int i=n-1,j=n;i>0;--i)
	{
		kk--;
		if(dep[i]!=dep[i+1])
			pp+=kk;
		while(j>1&&k-kk>0&&pp>=dep[i]-dep[j])
			kk++,pp-=(dep[i]-dep[j]),j--;
		res=max(res,kk);
	}
	cout<<res<<endl;
	return 0;
}


#include <vector>
#include <list>
#include <map>
#include <set>
#include <queue>
#include <deque>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <ctime>
#include <cstring>

using namespace std;

typedef long long i64 ;

vector<int>g[110000];
int dep[110000];
void dfs(int x,int f)
{
	for(int i=0;i<g[x].size();++i)
	{
		if(g[x][i]==f)	continue;
		dep[g[x][i]]=dep[x]+1;
		dfs(g[x][i],x);
	}
}

int main()
{
	int n,u,v;
	i64 k,p;
	cin>>n>>k>>p;
	for(int i=1;i<n;++i)
	{
		cin>>u>>v;
		g[u].push_back(v);
		g[v].push_back(u);
	}
	if(k==0)
	{
		puts("0");
		return 0;
	}
	dfs(1,0);
	sort(dep,dep+n);
	i64 kk=1,pp=p,res=1;
	for(int i=n-1,j=n;i>0;--i)
	{
		kk--;
		if(dep[i]!=dep[i+1])
			pp+=kk;
		while(j>1&&k-kk>0&&pp>=dep[i]-dep[j])
			j--,kk++,pp-=(dep[i]-dep[j]);
		res=max(res,kk);
	}
	cout<<res<<endl;
	return 0;
}


#include <vector>
#include <list>
#include <map>
#include <set>
#include <queue>
#include <deque>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <ctime>
#include <cstring>

using namespace std;

typedef long long i64 ;

vector<int>g[110000];
int dep[110000];
void dfs(int x,int f)
{
	for(int i=0;i<g[x].size();++i)
	{
		if(g[x][i]==f)	continue;
		dep[g[x][i]]=dep[x]+1;
		dfs(g[x][i],x);
	}
}

int main()
{
	int n,u,v;
	i64 k,p;
	cin>>n>>k>>p;
	for(int i=1;i<n;++i)
	{
		cin>>u>>v;
		g[u].push_back(v);
		g[v].push_back(u);
	}
	if(k==0)
	{
		puts("0");
		return 0;
	}
	dfs(1,0);
	sort(dep,dep+n);
	i64 kk=1,pp=p,res=1;
	for(int i=n-1,j=n-1;i>0;--i)
	{
		kk--;
		if(dep[i]!=dep[i+1])
			pp+=kk;
		while(j>0&&k-kk>0&&pp>=dep[i]-dep[j])
			kk++,pp-=(dep[i]-dep[j]),j--;
		res=max(res,kk);
	}
	cout<<res<<endl;
	return 0;
}


#include <vector>
#include <list>
#include <map>
#include <set>
#include <queue>
#include <deque>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <ctime>
#include <cstring>

using namespace std;

typedef long long i64 ;

vector<int>g[110000];
int dep[110000];
void dfs(int x,int f)
{
    for(int i=0;i<g[x].size();++i)
    {
        if(g[x][i]==f)  continue;
        dep[g[x][i]-1]=dep[x-1]+1;
        dfs(g[x][i],x);
    }
}

int main()
{
    int n,u,v;
    i64 k,p;
    cin>>n>>k>>p;
    for(int i=1;i<n;++i)
    {
        cin>>u>>v;
        g[u].push_back(v);
        g[v].push_back(u);
    }
    if(k==0)
    {
        puts("0");
        return 0;
    }
    dfs(1,0);
    sort(dep,dep+n);
    i64 pp=p,res=1;
    for(int i=n-1,j=n-1;i>0;--i)
    {
        if(dep[i]!=dep[i+1])
            pp+=i-j;
        while(j>0&&k>i-j&&pp>=dep[i]-dep[j])
            pp-=(dep[i]-dep[j]),j--;
        i64 kk=i-j;
        res=max(res,kk);
    }
    cout<<res<<endl;
    return 0;
}


#include <vector>
#include <list>
#include <map>
#include <set>
#include <queue>
#include <deque>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <ctime>
#include <cstring>

using namespace std;

typedef long long i64 ;

vector<int>g[110000];
int dep[110000];
void dfs(int x,int f)
{
	for(int i=0;i<g[x].size();++i)
	{
		if(g[x][i]==f)	continue;
		dep[g[x][i]]=dep[x]+1;
		dfs(g[x][i],x);
	}
}

int main()
{
	int n,u,v;
	i64 k,p;
	cin>>n>>k>>p;
	for(int i=1;i<n;++i)
	{
		cin>>u>>v;
		g[u].push_back(v);
		g[v].push_back(u);
	}
	if(k==0)
	{
		puts("0");
		return 0;
	}
	dfs(1,0);
	sort(dep,dep+n);
	i64 pp=p,res=1;
	for(int i=n-1,j=n-1;i>0;--i)
	{
		if(dep[i]!=dep[i+1])
			pp+=i-j;
		while(j>0&&k>i-j&&pp>=dep[i]-dep[j])
			pp-=(dep[i]-dep[j]),j--;
		i64 kk=i-j;
		res=max(res,kk);
	}
	cout<<res<<endl;
	return 0;
}


#include <vector>
#include <list>
#include <map>
#include <set>
#include <queue>
#include <deque>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <ctime>
#include <cstring>

using namespace std;

typedef long long i64 ;

vector<int>g[110000];
int dep[110000];
void dfs(int x,int f)
{
	for(int i=0;i<=g[x].size();++i)
	{
		if(g[x][i]==f)	continue;
		dep[g[x][i]]=dep[x]+1;
	}
}

int main()
{
	int n,u,v;
	i64 k,p;
	cin>>n>>k>>p;
	for(int i=1;i<n;++i)
	{
		cin>>u>>v;
		g[u].push_back(v);
		g[v].push_back(u);
	}
	if(k==0)
	{
		puts("0");
		return 0;
	}
	dfs(1,0);
	sort(dep,dep+n);
	i64 kk=0,pp=p,res=1;
	for(int i=n-1,j=n;i>0;--i)
	{
		kk--;
		pp+=kk;
		while(kk>0&&pp>=i-j)
			j--,kk++,pp-=(i-j);
		res=max(res,kk);
	}
	cout<<res<<endl;
	return 0;
}


#include <cstdio>
#include <cstring>
#include <algorithm>
#include <queue>

using namespace std;

const int Maxn = 100000 * 2;

class Graph
{
public:
    int head[Maxn], Next[Maxn * 2], No[Maxn * 2], tot;
    void init()
    {
        tot = 1;
        memset(head, 0, sizeof head);
    }
    void add(int x, int y)
    {
        Next[tot] = head[x];
        head[x] = tot;
        No[tot++] = y;
    }
}G;

int dep[Maxn], cnt[Maxn];

int main()
{
    int n, k, p;
    scanf("%d%d%d", &n, &k, &p);
    G.init();
    for(int i = 0; i < n - 1; ++i)
    {
        int x, y;
        scanf("%d%d", &x, &y);
        G.add(x, y), G.add(y, x);
    }
    queue<int> q;
    memset(dep, -1, sizeof dep);
    q.push(1); dep[1] = 0, cnt[0] = 1;
    int mxdep = 0;
    while(!q.empty())
    {
        int cur = q.front();
        q.pop();
        for(int i = G.head[cur]; i; i = G.Next[i])
        {
            int y = G.No[i];
            if(dep[y] != -1) continue;
            dep[y] = dep[cur] + 1;
            cnt[dep[y]]++;
            q.push(y);
            mxdep = max(mxdep, dep[y]);
        }
    }
    long long cost = 0;int sum = 0;
    int ans = 0;
    int st = mxdep, ed = mxdep + 1;
   for(;;)
    {
        --ed; if(ed <= 0) break;
        long long wait = st - ed;
        if(wait * cnt[ed] + cost >= p)
        {
            int rem = (p - cost) / wait;
            ans = max(ans, sum + rem);
            while(wait * cnt[ed] + cost >= p)
            {
                sum -= cnt[st];
                cost -= sum;
                st--;
                wait--;
            }
            cost += wait * cnt[ed];
            sum += cnt[ed];
            ans = max(ans, sum);
        }
        else
        {
            cost += wait * cnt[ed];
            sum += cnt[ed];
            ans = max(ans, sum);
        }    }
    printf("%d\n", (int)min(ans, k));
    return 0;
}


#include <cstdio>
#include <cstring>
#include <algorithm>
#include <queue>

using namespace std;

const int Maxn = 100000 * 2;

class Graph
{
public:
    int head[Maxn], Next[Maxn * 2], No[Maxn * 2], tot;
    void init()
    {
        tot = 1;
        memset(head, 0, sizeof head);
    }
    void add(int x, int y)
    {
        Next[tot] = head[x];
        head[x] = tot;
        No[tot++] = y;
    }
}G;

int dep[Maxn], cnt[Maxn];

int main()
{
    int n, k, p;
    scanf("%d%d%d", &n, &k, &p);
    G.init();
    for(int i = 0; i < n - 1; ++i)
    {
        int x, y;
        scanf("%d%d", &x, &y);
        G.add(x, y), G.add(y, x);
    }
    queue<int> q;
    memset(dep, -1, sizeof dep);
    q.push(1); dep[1] = 0, cnt[0] = 1;
    while(!q.empty())
    {
        int cur = q.front();
        q.pop();
        for(int i = G.head[cur]; i; i = G.Next[i])
        {
            int y = G.No[i];
            if(dep[y] != -1) continue;
            dep[y] = dep[cur] + 1;
            cnt[dep[y]]++;
            q.push(y);
        }
    }
    long long cost = 0;int sum = 0;
    for(int i = 1; cnt[i] != 0; ++i)
    {
        int cur = cnt[i];
        if(cost + sum <= p)
        {
            cost += sum;
            sum += cnt[i];
        }
        else
        {
            break;
        }
    }
    printf("%d\n", (int)min(sum, k));
    return 0;
}


#include <cstdio>
#include <cstring>
#include <algorithm>
#include <queue>

using namespace std;

const int Maxn = 100000 * 2;

class Graph
{
public:
    int head[Maxn], Next[Maxn * 2], No[Maxn * 2], tot;
    void init()
    {
        tot = 1;
        memset(head, 0, sizeof head);
    }
    void add(int x, int y)
    {
        Next[tot] = head[x];
        head[x] = tot;
        No[tot++] = y;
    }
}G;

int dep[Maxn], cnt[Maxn];

int main()
{
    int n, k, p;
    scanf("%d%d%d", &n, &k, &p);
    G.init();
    for(int i = 0; i < n - 1; ++i)
    {
        int x, y;
        scanf("%d%d", &x, &y);
        G.add(x, y), G.add(y, x);
    }
    queue<int> q;
    memset(dep, -1, sizeof dep);
    q.push(1); dep[1] = 0, cnt[0] = 1;
    int mxdep = 0;
    while(!q.empty())
    {
        int cur = q.front();
        q.pop();
        for(int i = G.head[cur]; i; i = G.Next[i])
        {
            int y = G.No[i];
            if(dep[y] != -1) continue;
            dep[y] = dep[cur] + 1;
            cnt[dep[y]]++;
            q.push(y);
            mxdep = max(mxdep, dep[y]);
        }
    }
    long long cost = 0;int sum = 0;
    int ans = 0;
    int st = mxdep, ed = mxdep + 1;
    for(;;)
    {
        --ed; if(ed <= 0) break;
        long long wait = ed - st;
        if(wait * cnt[ed] + cost >= p)
        {
            int rem = (p - cost) / wait;
            ans = max(ans, sum + rem);
            while(wait * cnt[ed] + cost >= p)
            {
                sum -= cnt[st];
                cost -= cnt[st];
                st--;
                wait--;
            }
            cost += wait * cnt[ed];
            sum += cnt[ed];
        }
        else
        {
            cost += wait * cnt[ed];
            sum += cnt[ed];
            ans = max(ans, sum);
        }
    }
    printf("%d\n", (int)min(ans, k));
    return 0;
}


#include <cstdio>
#include <vector>

using namespace std;

#define repi(i,a) for(typeof((a).begin()) i = (a).begin(), _##i = (a).end(); i != _##i; ++i)
const int MAXN = 100100;

typedef long long ll;

vector<int> conn[MAXN];

int cnt[MAXN];

int N, K, P;

void dfs(int cur, int prv = 0, int dpth = 0) {
  ++cnt[dpth];
  repi(i, conn[cur]) {
    int nxt = *i;
    if (nxt != prv) {
      dfs(nxt, cur, dpth + 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);
    conn[a].push_back(b);
    conn[b].push_back(a);
  }

  dfs(1);

  int lft = 1, rgt = 1;
  ll cur = 0;
  int tot = 0;
  int ans = 0;

  while (rgt < N) {
    //printf("lft = %d, rgt = %d, cur = %ll d, tot = %d\n", lft, rgt, cur, tot);
    if (cur <= P) {
      if (tot > ans) ans = tot;
      cur += tot;
      tot += cnt[rgt];
      ++rgt;
    } else {
      cur -= cnt[lft] * ll(rgt - lft - 1);
      tot -= cnt[lft];
      ++lft;
    }
  }

  if (ans > K) ans = K;

  printf("%d\n", ans);
  return 0;
}


#include <cstdio>
#include <vector>

using namespace std;

#define repi(i,a) for(typeof((a).begin()) i = (a).begin(), _##i = (a).end(); i != _##i; ++i)
const int MAXN = 100100;

typedef long long ll;

vector<int> conn[MAXN];

int cnt[MAXN];

int N, K, P;

void dfs(int cur, int prv = 0, int dpth = 0) {
  ++cnt[dpth];
  repi(i, conn[cur]) {
    int nxt = *i;
    if (nxt != prv) {
      dfs(nxt, cur, dpth + 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);
    conn[a].push_back(b);
    conn[b].push_back(a);
  }

  dfs(1);

  int lft = 1, rgt = 1;
  ll cur = 0;
  int tot = 0;
  int ans = 0;

  while (rgt <= N) {
    //printf("lft = %d, rgt = %d, cur = %ll d, tot = %d\n", lft, rgt, cur, tot);
    if (cur <= P) {
      if (tot > ans) ans = tot;
      cur += tot;
      tot += cnt[rgt];
      ++rgt;
    } else {
      cur -= cnt[lft] * ll(rgt - lft - 1);
      tot -= cnt[lft];
      ++lft;
    }
  }

  if (ans > K) ans = K;

  printf("%d\n", ans);
  return 0;
}


#include <cstdio>
#include <vector>

using namespace std;

#define repi(i,a) for(typeof((a).begin()) i = (a).begin(), _##i = (a).end(); i != _##i; ++i)
const int MAXN = 100100;

typedef long long ll;

vector<int> conn[MAXN];

int cnt[MAXN];

int N, K, P;

void dfs(int cur, int prv = 0, int dpth = 0) {
  ++cnt[dpth];
  repi(i, conn[cur]) {
    int nxt = *i;
    if (nxt != prv) {
      dfs(nxt, cur, dpth + 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);
    conn[a].push_back(b);
    conn[b].push_back(a);
  }

  dfs(1);

  int lft = 1, rgt = 1;
  ll cur = 0;
  int tot = 0;
  int ans = 0;

  while (rgt <= N) {
    //printf("lft = %d, rgt = %d, cur = %ll d, tot = %d\n", lft, rgt, cur, tot);
    if (cur <= P) {
      ll extr = P - cur;
      int cand = tot;
      if (lft > 1) {
        int len = rgt - lft;
        int get = extr / len;
        cand += get;
      }
      if (cand > ans) ans = cand;

      cur += tot;
      tot += cnt[rgt];
      ++rgt;
    } else {
      cur -= cnt[lft] * ll(rgt - lft - 1);
      tot -= cnt[lft];
      ++lft;
    }
  }

  if (ans > K) ans = K;

  printf("%d\n", ans);
  return 0;
}


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

const int maxn = 100001;
typedef long long ll;
int m, k, p, ans, dep[maxn];
ll sum[maxn];
vector<int> rou[maxn];
void Search(int u) {
  for (int i = 0; i < rou[u].size(); i++)
    if (dep[rou[u][i]] == 0) {
      dep[rou[u][i]] = dep[u]+1;
      Search(rou[u][i]);
    }
}
int Check(int x, int l, int r) {
  int m;
  while (l+1 < r) {
    m = (l+r)>>1;
    if (sum[x]-sum[m-1]+p < 1LL*(x-m+1)*dep[x]) l = m; else r = m;
  }
  return r;
}
int main()
{
  scanf("%d%d%d", &m, &k, &p);
  int u, v, tmp;
  for (int i = 1; i < m; i++) {
    scanf("%d%d", &u, &v);
    rou[u].push_back(v);
    rou[v].push_back(u);
  }
  ans = dep[1] = 1;
  Search(1);
  sort(dep+1, dep+m+1);
  for (int i = 2; i <= m; i++) sum[i] = sum[i-1]+dep[i];
  for (int i = 2; i <= m; i++) {
    tmp = i-Check(i, 1, i)+1;
    if (tmp > ans) ans = tmp;
  }
  if (ans > k) printf("%d\n", k); else printf("%d\n", ans);
}


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

const int maxn = 100001;
int m, k, p, ans, dep[maxn], sum[maxn];
vector<int> rou[maxn];
void Search(int u) {
  for (int i = 0; i < rou[u].size(); i++)
    if (dep[rou[u][i]] == 0) {
      dep[rou[u][i]] = dep[u]+1;
      Search(rou[u][i]);
    }
}
int Check(int x, int l, int r) {
  int m;
  while (l+1 < r) {
    m = (l+r)>>1;
    if (sum[x]-sum[m-1]+p < (x-m+1)*dep[x]) l = m; else r = m;
  }
  return r;
}
int main()
{
  scanf("%d%d%d", &m, &k, &p);
  int u, v, tmp;
  for (int i = 1; i < m; i++) {
    scanf("%d%d", &u, &v);
    rou[u].push_back(v);
    rou[v].push_back(u);
  }
  ans = dep[1] = 1;
  Search(1);
  sort(dep+1, dep+m+1);
  for (int i = 2; i <= m; i++) sum[i] = sum[i-1]+dep[i];
  for (int i = 2; i <= m; i++) {
    tmp = i-Check(i, 1, i)+1;
    if (tmp > ans) ans = tmp;
  }
  if (ans > k) printf("%d\n", k); else printf("%d\n", ans);
}


#include<iostream>
#include<cstdio>
#include<cstring>
#include<algorithm>
#include<cmath>
#include<cstdlib>
#include<map>
using namespace std;

#define rep(i, s, t) for (int i = (s); i <= (t); ++i)
#define per(i, s, t) for (int i = (s); i >= (t); --i)
#define REP(i, n) rep(i, 1, n)
#define PER(i, n) rep(i, n, 1)
#define X first
#define Y second
#define mk make_pair
#define MOD 1000000007
typedef long long LL;

const int MAX_N = 111111;
int g[MAX_N << 1], nxt[MAX_N << 1], c[MAX_N], nm;
int n, m, p;
int d[MAX_N];

void dfs(int x, int fa, int dep){
    d[x] = dep;
    for (int k = c[x]; ~k; k = nxt[k]){
        int j = g[k];
        if (j != fa) dfs(j, x, dep + 1);
    }
}

void addedge(int x, int y){
    g[nm] = y; nxt[nm] = c[x]; c[x] = nm; nm++;
}

int main(){
    memset(c, -1, sizeof c);
    scanf("%d%d%d", &n, &m, &p);
    m = min(m, n - 1);
    REP(i, n - 1){
        int x, y;
        scanf("%d%d", &x, &y);
        addedge(x, y);
        addedge(y, x);
    }
    dfs(1, -1, 0);
    sort(d + 1, d + 1 + n);
    int f = 1, ans = 0;
    REP(i, n){
        if (d[i] != d[i - 1]) p -= i - f;
        while (p < 0) p += d[i] - d[f++];
        ans = max(ans, i - f + 1);
    }
    cout << min(ans, m) << endl;
    //system("pause");
}


#include<iostream>
#include<cstdio>
#include<cstring>
#include<algorithm>
#include<cmath>
#include<cstdlib>
#include<map>
using namespace std;

#define rep(i, s, t) for (int i = (s); i <= (t); ++i)
#define per(i, s, t) for (int i = (s); i >= (t); --i)
#define REP(i, n) rep(i, 1, n)
#define PER(i, n) rep(i, n, 1)
#define X first
#define Y second
#define mk make_pair
#define MOD 1000000007
typedef long long LL;

const int MAX_N = 111111;
int g[MAX_N << 1], nxt[MAX_N << 1], c[MAX_N], nm;
int n, m, p;
int d[MAX_N];

void dfs(int x, int fa, int dep){
    d[x] = dep;
    for (int k = c[x]; ~k; k = nxt[k]){
        int j = g[k];
        if (j != fa) dfs(j, x, dep + 1);
    }
}

void addedge(int x, int y){
    g[nm] = y; nxt[nm] = c[x]; c[x] = nm; nm++;
}

int main(){
    memset(c, -1, sizeof c);
    scanf("%d%d%d", &n, &m, &p);
    m = max(m, n - 1);
    REP(i, n - 1){
        int x, y;
        scanf("%d%d", &x, &y);
        addedge(x, y);
        addedge(y, x);
    }
    dfs(1, -1, 0);
    sort(d + 1, d + 1 + n);
    int f = 1, ans = 0;
    REP(i, n){
        if (d[i] != d[i - 1]) p -= i - f;
        while (p < 0) p += d[i] - d[f++];
        ans = max(ans, i - f + 1);
    }
    cout << min(ans, m) << endl;
    //system("pause");
}


#include<iostream>
#include<cstdio>
#include<cstring>
#include<algorithm>
#include<cmath>
#include<cstdlib>
#include<map>
using namespace std;

#define rep(i, s, t) for (int i = (s); i <= (t); ++i)
#define per(i, s, t) for (int i = (s); i >= (t); --i)
#define REP(i, n) rep(i, 1, n)
#define PER(i, n) rep(i, n, 1)
#define X first
#define Y second
#define mk make_pair
#define MOD 1000000007
typedef long long LL;

const int MAX_N = 111111;
int g[MAX_N << 1], nxt[MAX_N << 1], c[MAX_N], nm;
int n, m, p;
int d[MAX_N];

void dfs(int x, int fa, int dep){
    d[x] = dep;
    for (int k = c[x]; ~k; k = nxt[k]){
        int j = g[k];
        if (j != fa) dfs(j, x, dep + 1);
    }
}

void addedge(int x, int y){
    g[nm] = y; nxt[nm] = c[x]; c[x] = nm; nm++;
}

int main(){
    memset(c, -1, sizeof c);
    scanf("%d%d%d", &n, &m, &p);
    REP(i, n - 1){
        int x, y;
        scanf("%d%d", &x, &y);
        addedge(x, y);
        addedge(y, x);
    }
    dfs(1, -1, 0);
    sort(d + 1, d + 1 + n);
    int f = 1, ans = 0;
    REP(i, n){
        if (d[i] != d[i - 1]) p -= i - f;
        while (p < 0) p += d[i] - d[f++];
        ans = max(ans, i - f + 1);
    }
    cout << min(ans, m) << endl;
    //system("pause");
}


#include<iostream>
#include<cstdio>
#include<cstring>
#include<algorithm>
#include<cmath>
#include<cstdlib>
#include<map>
using namespace std;

#define rep(i, s, t) for (int i = (s); i <= (t); ++i)
#define per(i, s, t) for (int i = (s); i >= (t); --i)
#define REP(i, n) rep(i, 1, n)
#define PER(i, n) rep(i, n, 1)
#define X first
#define Y second
#define mk make_pair
#define MOD 1000000007
typedef long long LL;

const int MAX_N = 111111;
int g[MAX_N << 1], nxt[MAX_N << 1], c[MAX_N], nm;
int n, m, p;
int d[MAX_N];

void dfs(int x, int fa, int dep){
    d[x] = dep;
    for (int k = c[x]; ~k; k = nxt[k]){
        int j = g[k];
        if (j != fa) dfs(j, x, dep + 1);
    }
}

void addedge(int x, int y){
    g[nm] = y; nxt[nm] = c[x]; c[x] = nm; nm++;
}

int main(){
    memset(c, -1, sizeof c);
    int p2;
    scanf("%d%d%d", &n, &m, &p2);
    LL p = p2;
    m = min(m, n - 1);
    REP(i, n - 1){
        int x, y;
        scanf("%d%d", &x, &y);
        addedge(x, y);
        addedge(y, x);
    }
    dfs(1, -1, 0);
    sort(d + 1, d + 1 + n);
    int f = 2, ans = 0;
    rep(i, 3, n){
        if (d[i] != d[i - 1]) p -= i - f;
        while (p < 0) p += d[i] - d[f++];
        ans = max(ans, i - f + 1);
    }
    cout << min(ans, m) << endl;
    //system("pause");
}


#include<iostream>
#include<cstdio>
#include<cstring>
#include<algorithm>
#include<cmath>
#include<cstdlib>
#include<map>
using namespace std;

#define rep(i, s, t) for (int i = (s); i <= (t); ++i)
#define per(i, s, t) for (int i = (s); i >= (t); --i)
#define REP(i, n) rep(i, 1, n)
#define PER(i, n) rep(i, n, 1)
#define X first
#define Y second
#define mk make_pair
#define MOD 1000000007
typedef long long LL;

const int MAX_N = 111111;
int g[MAX_N << 1], nxt[MAX_N << 1], c[MAX_N], nm;
int n, m, p;
int d[MAX_N];

void dfs(int x, int fa, int dep){
    d[x] = dep;
    for (int k = c[x]; ~k; k = nxt[k]){
        int j = g[k];
        if (j != fa) dfs(j, x, dep + 1);
    }
}

void addedge(int x, int y){
    g[nm] = y; nxt[nm] = c[x]; c[x] = nm; nm++;
}

int main(){
    memset(c, -1, sizeof c);
    int p2;
    scanf("%d%d%d", &n, &m, &p2);
    LL p = p2;
    m = min(m, n - 1);
    REP(i, n - 1){
        int x, y;
        scanf("%d%d", &x, &y);
        addedge(x, y);
        addedge(y, x);
    }
    dfs(1, -1, 0);
    sort(d + 1, d + 1 + n);
    int f = 1, ans = 0;
    REP(i, n){
        if (d[i] != d[i - 1]) p -= i - f;
        while (p < 0) p += d[i] - d[f++];
        ans = max(ans, i - f + 1);
    }
    cout << min(ans, m) << endl;
    //system("pause");
}


#pragma comment(linker, "/STACK:500000000")
#include<cstdio>
#include<cstdlib>
#include<iostream>
#include<cstring>
#include<string>
#include<ctime>
#include<cmath>
#include<utility>
#include<set>
#include<vector>
#include<map>
#include<queue>
#include<algorithm>
#define INF 1111111111
#define N 111111
#define eps 1e-9
using namespace std;
typedef long long LL;
int getint()
{
	char ch;
	do
	{
		ch=getchar();
	}while (ch!='-'&&(ch<'0'||ch>'9'));
	int ans=0,f=0;
	if (ch=='-') f=1; else ans=ch-'0';
	while (isdigit(ch=getchar())) ans=ans*10+ch-'0';
	if (f) ans*=-1;
	return ans;
}
struct edge
{
	int t,n;
}e[N*2];
struct point
{
	int d,w;
	bool operator < (const point&rhs) const
	{
		if (d!=rhs.d) return d>rhs.d;
		return w>rhs.w;
	}
}P[N];
int h[N],cnt[100][N];
int n,k,p,tote,idx,son,ans=1;
void adde(int f,int t)
{
	e[++tote].t=t;
	e[tote].n=h[f];
	h[f]=tote;
	return ;
}
int U[N],FA[N],BEL[N],DEP[N];
void dfs(int u,int fa,int bel,int dep)
{
	int l=1,r=1;
	U[l]=u; FA[l]=fa; BEL[l]=bel; DEP[l]=dep;
	while (l<=r)
	{
		u=U[l]; fa=FA[l]; bel=BEL[l]; dep=DEP[l];
		cnt[bel][dep]++;
		for (int i=h[u];i;i=e[i].n)
		{
			int v=e[i].t;
			if (v==fa) continue;
			U[++r]=v; FA[r]=u; BEL[r]=bel; DEP[r]=dep+1;
		}
		l++;
	}
	return ;
}
int sum1[N];
LL sum2[N];
int main()
{
	n=getint(); k=getint(); p=getint();
	for (int i=1;i<n;i++)
	{
		int u=getint(),v=getint();
		adde(u,v); adde(v,u);
	}
	for (int i=h[1];i;i=e[i].n)
	{
		int v=e[i].t;
		dfs(v,1,++son,1);
	}
	if (son>50) while (1);
	for (int i=1;i<=son;i++)
	for (int j=1;j<=n;j++)
	if (cnt[i][j]) P[++idx].d=j,P[idx].w=cnt[i][j];
	sort(&P[1],&P[idx+1]);
	for (int i=1;i<=idx;i++)
	{
		sum1[i]=sum1[i-1]+P[i].w;
		sum2[i]=sum2[i-1]+(LL)P[i].w*P[i].d;
	}
	for (int i=1;i<=idx;i++)
	{
		int r=i,ll=i,rr=idx;
		while (ll<=rr)
		{
			int mid=(ll+rr)>>1;
			if ((LL)P[i].d*(sum1[mid]-sum1[i-1])-(sum2[mid]-sum2[i-1])<=p) r=mid,ll=mid+1;
			else rr=mid-1;
		}
		LL pp=(LL)P[i].d*(sum1[r]-sum1[i-1])-(sum2[r]-sum2[i-1]);
		if (r==idx) ans=max(ans,sum1[r]-sum1[i-1]);
		else
		{
			int tmp=sum1[r]-sum1[i-1]+(p-pp)/(P[i].d-P[r+1].d);
			ans=max(ans,tmp);
		}
	}
	ans=min(ans,k);
	printf("%d\n",ans);
	return 0;
}


#include<cstdio>
#include<cstdlib>
#include<iostream>
#include<cstring>
#include<string>
#include<ctime>
#include<cmath>
#include<utility>
#include<set>
#include<vector>
#include<map>
#include<queue>
#include<algorithm>
#define INF 1111111111
#define N 111111
#define eps 1e-9
using namespace std;
typedef long long LL;
int getint()
{
	char ch;
	do
	{
		ch=getchar();
	}while (ch!='-'&&(ch<'0'||ch>'9'));
	int ans=0,f=0;
	if (ch=='-') f=1; else ans=ch-'0';
	while (isdigit(ch=getchar())) ans=ans*10+ch-'0';
	if (f) ans*=-1;
	return ans;
}
struct edge
{
	int t,n;
}e[N*2];
struct point
{
	int d,w;
	bool operator < (const point&rhs) const
	{
		if (d!=rhs.d) return d>rhs.d;
		return w>rhs.w;
	}
}P[N];
int h[N],cnt[33][N];
int n,k,p,tote,idx,son,ans=1;
void adde(int f,int t)
{
	e[++tote].t=t;
	e[tote].n=h[f];
	h[f]=tote;
	return ;
}
void dfs(int u,int fa,int bel,int dep)
{
	cnt[bel][dep]++;
	for (int i=h[u];i;i=e[i].n)
	{
		int v=e[i].t;
		if (v==fa) continue;
		dfs(v,u,bel,dep+1);
	}
	return ;
}
int main()
{
	n=getint(); k=getint(); p=getint();
	for (int i=1;i<n;i++)
	{
		int u=getint(),v=getint();
		adde(u,v); adde(v,u);
	}
	for (int i=h[1];i;i=e[i].n)
	{
		int v=e[i].t;
		dfs(v,1,++son,1);
	}
	for (int i=1;i<=son;i++)
	for (int j=1;j<=n;j++)
	if (cnt[i][j]) P[++idx].d=j,P[idx].w=cnt[i][j];
	sort(&P[1],&P[idx+1]);
	if (!k)
	{
		printf("0");
		return 0;
	}
	int r=1,t=0,tot=0,cnt=0;
	for (int i=1;i<=idx;i++)
	{
		r=i; tot=P[i].w; cnt=0;
		while (P[r+1].d==P[i].d)
		{
			r++;
			tot+=P[r].w;
		}
		while (r<idx&&(P[i].d-P[r+1].d)*(cnt+P[r+1].w)<=p)
		{
			r++;
			cnt+=P[r].w;
			tot+=P[r].w;
		}
		if (r==idx) ans=max(ans,tot);
		else ans=max(ans,tot+(p/(P[i].d-P[r+1].d)-cnt));
	}
	ans=min(ans,k);
	printf("%d\n",ans);
	return 0;
}


#include<cstdio>
#include<cstdlib>
#include<iostream>
#include<cstring>
#include<string>
#include<ctime>
#include<cmath>
#include<utility>
#include<set>
#include<vector>
#include<map>
#include<queue>
#include<algorithm>
#define INF 1111111111
#define N 111111
#define eps 1e-9
using namespace std;
typedef long long LL;
int getint()
{
	char ch;
	do
	{
		ch=getchar();
	}while (ch!='-'&&(ch<'0'||ch>'9'));
	int ans=0,f=0;
	if (ch=='-') f=1; else ans=ch-'0';
	while (isdigit(ch=getchar())) ans=ans*10+ch-'0';
	if (f) ans*=-1;
	return ans;
}
struct edge
{
	int t,n;
}e[N*2];
struct point
{
	int d,w;
	bool operator < (const point&rhs) const
	{
		if (d!=rhs.d) return d>rhs.d;
		return w>rhs.w;
	}
}P[N];
int h[N],cnt[33][N];
int n,k,p,tote,idx,son,ans=1;
void adde(int f,int t)
{
	e[++tote].t=t;
	e[tote].n=h[f];
	h[f]=tote;
	return ;
}
void dfs(int u,int fa,int bel,int dep)
{
	cnt[bel][dep]++;
	for (int i=h[u];i;i=e[i].n)
	{
		int v=e[i].t;
		if (v==fa) continue;
		dfs(v,u,bel,dep+1);
	}
	return ;
}
int main()
{
	n=getint(); k=getint(); p=getint();
	for (int i=1;i<n;i++)
	{
		int u=getint(),v=getint();
		adde(u,v); adde(v,u);
	}
	for (int i=h[1];i;i=e[i].n)
	{
		int v=e[i].t;
		dfs(v,1,++son,1);
	}
	for (int i=1;i<=son;i++)
	for (int j=1;j<=n;j++)
	if (cnt[i][j]) P[++idx].d=j,P[idx].w=cnt[i][j];
	sort(&P[1],&P[idx+1]);
	if (!k)
	{
		printf("0");
		return 0;
	}
	int r=1,t=0,tot=0;
	for (int i=1;i<=idx;i++)
	{
		r=max(r,i);
		t=max(t,1);
		tot=max(P[i].w,tot);
		while (r<idx)
		{
			if (P[r+1].d==P[r].d)
			{
				r++;
				tot+=P[r].w;
			}
			else if (t<p)
			{
				r++; t++;
				tot+=P[r].w;
			}
			else break;
		}
		ans=max(ans,tot);
		if (r==i||P[i].d!=P[i+1].d) t--;
		tot-=P[i].w;
	}
	ans=min(ans,k);
	printf("%d\n",ans);
	return 0;
}


#include<cstdio>
#include<cstdlib>
#include<iostream>
#include<cstring>
#include<string>
#include<ctime>
#include<cmath>
#include<utility>
#include<set>
#include<vector>
#include<map>
#include<queue>
#include<algorithm>
#define INF 1111111111
#define N 111111
#define eps 1e-9
using namespace std;
typedef long long LL;
int getint()
{
	char ch;
	do
	{
		ch=getchar();
	}while (ch!='-'&&(ch<'0'||ch>'9'));
	int ans=0,f=0;
	if (ch=='-') f=1; else ans=ch-'0';
	while (isdigit(ch=getchar())) ans=ans*10+ch-'0';
	if (f) ans*=-1;
	return ans;
}
struct edge
{
	int t,n;
}e[N*2];
struct point
{
	int d,w;
	bool operator < (const point&rhs) const
	{
		if (d!=rhs.d) return d>rhs.d;
		return w>rhs.w;
	}
}P[N];
int h[N],cnt[33][N];
int n,k,p,tote,idx,son,ans=1;
void adde(int f,int t)
{
	e[++tote].t=t;
	e[tote].n=h[f];
	h[f]=tote;
	return ;
}
void dfs(int u,int fa,int bel,int dep)
{
	cnt[bel][dep]++;
	for (int i=h[u];i;i=e[i].n)
	{
		int v=e[i].t;
		if (v==fa) continue;
		dfs(v,u,bel,dep+1);
	}
	return ;
}
int main()
{
	n=getint(); k=getint(); p=getint();
	for (int i=1;i<n;i++)
	{
		int u=getint(),v=getint();
		adde(u,v); adde(v,u);
	}
	for (int i=h[1];i;i=e[i].n)
	{
		int v=e[i].t;
		dfs(v,1,++son,1);
	}
	for (int i=1;i<=son;i++)
	for (int j=1;j<=n;j++)
	if (cnt[i][j]) P[++idx].d=j,P[idx].w=cnt[i][j];
	sort(&P[1],&P[idx+1]);
	if (!k)
	{
		printf("0");
		return 0;
	}
	int r=1,t=0,tot=0,cnt=0;
	for (int i=1;i<=idx;i++)
	{
		r=i; tot=P[i].w; cnt=0;
		while (P[r+1].d==P[i].d)
		{
			r++;
			tot+=P[r].w;
		}
		while (r<idx&&(P[i].d-P[r+1].d)*(cnt+P[r+1].w)<=p)
		{
			r++;
			cnt+=P[r].w;
			tot+=P[r].w;
		}

		ans=max(ans,tot+(p/(P[i].d-P[r+1].d)-cnt));
	}
	ans=min(ans,k);
	printf("%d\n",ans);
	return 0;
}