#include<bits/stdc++.h>

#define task "inp"
#define rep(i,l,r) for (int i = (l) ; i <= (r) ; ++i)
#define Rep(i,r,l) for (int i = (r) ; i >= (l) ; --i)
#define all(x) (x).begin(),(x).end()
#define allar(x,_,__) (x) + (_), (x) + (_) + (__)
#define pb push_back
#define pob pop_back
#define pof pop_front
#define pf push_front
#define mp make_pair
#define f first
#define s second
#define c_zh(x) __builtin_clz((x))
#define c_zl(x) __builtin_ctz((x))
#define c_o(x) __builtin_popcount((x))
#define o_e(x) __builtin_parity((x))

using namespace std;

typedef vector<int> vi;
typedef pair<int,int> pii;
typedef vector<pii> vii;
typedef vector<int,pii> viii;
typedef vector<long long> vll;
typedef long long ll;

int main()
{
    int t;
    cin >> t;
    while (t--)
    {
        int n, pos1;
        cin >> n;
        vector<int> a(n + 1);
        rep(i, 1, n) {
            cin >> a[i];
            if (a[i] == 1) pos1 = i;
        }
        bool flag = true;
        if (n == 1)
        {
            cout << "YES\n";
            continue;
        }
        if (a[pos1] == a[((pos1 + 1) == n) ? (pos1 + 1) : ((pos1 + 1) % n)] - 1)
        {
            int j = ((pos1 + 1) == n) ? (pos1 + 1) : ((pos1 + 1) % n);
            while (j != pos1)
            {
                if (((j + 1) == n) ? (j + 1) : ((j + 1) % n) == pos1) break;
                //cout <<j << " " << j + 1 << "\n";
                if (a[j] == a[((j + 1) == n) ? (j + 1) : ((j + 1) % n)] - 1)
                    j = (j + 1) % n;
                else {
                        flag = false;
                        break;
                }
            }
        }
        else if (a[pos1] == a[(pos1 - 1 == 0) ? (n) : (pos1 - 1)] - 1)
        {
            int j = (pos1 - 1 == 0) ? (n) : (pos1 - 1);
            while (j != pos1)
            {
                if (pos1 == ((j == 0) ? (n) : (j - 1))) break;
                if (a[j] == a[(j - 1 == 0) ? (n) : (j - 1)] - 1)
                    j = ((j - 1) == 0) ? (n) : (j - 1);
                else{
                    flag = false;
                    break;
                }
            }
        }else flag = false;
        (flag) ? (cout << "YES\n") : (cout << "NO\n");
    }
	return 0;
}


#include<bits/stdc++.h>

#define task "inp"
#define rep(i,l,r) for (int i = (l) ; i <= (r) ; ++i)
#define Rep(i,r,l) for (int i = (r) ; i >= (l) ; --i)
#define all(x) (x).begin(),(x).end()
#define allar(x,_,__) (x) + (_), (x) + (_) + (__)
#define pb push_back
#define pob pop_back
#define pof pop_front
#define pf push_front
#define mp make_pair
#define f first
#define s second
#define c_zh(x) __builtin_clz((x))
#define c_zl(x) __builtin_ctz((x))
#define c_o(x) __builtin_popcount((x))
#define o_e(x) __builtin_parity((x))

using namespace std;

typedef vector<int> vi;
typedef pair<int,int> pii;
typedef vector<pii> vii;
typedef vector<int,pii> viii;
typedef vector<long long> vll;
typedef long long ll;

int main()
{
    int t;
    cin >> t;
    while (t--)
    {
        int n, pos1;
        cin >> n;
        vector<int> a(n + 1);
        rep(i, 1, n) {
            cin >> a[i];
            if (a[i] == 1) pos1 = i;
        }
        bool flag = true;
        if (n == 1)
        {
            cout << "YES\n";
            continue;
        }
        if (a[pos1] == a[((pos1 + 1) % n == 0) ? (n) : ((pos1 + 1) % n)] - 1)
        {
            int j = ((pos1 + 1) % n == 0) ? (n) : ((pos1 + 1) % n);
            while (j != pos1)
            {
                if (((j + 1) % n == 0) ? (n) : ((j + 1) % n) == pos1) break;
                //cout <<j << " " << j + 1 << "\n";
                if (a[j] == a[((j + 1) % n == 0) ? (n) : ((j + 1) % n)] - 1)
                    j = ((j + 1) % n == 0) ? (n) : ((j + 1) % n);
                else {
                        flag = false;
                        break;
                }
            }
        }
        else if (a[pos1] == a[(pos1 - 1 == 0) ? (n) : (pos1 - 1)] - 1)
        {
            int j = (pos1 - 1 == 0) ? (n) : (pos1 - 1);
            while (j != pos1)
            {
                if (pos1 == ((j == 0) ? (n) : (j - 1))) break;
                if (a[j] == a[(j - 1 == 0) ? (n) : (j - 1)] - 1)
                    j = ((j - 1) == 0) ? (n) : (j - 1);
                else{
                    flag = false;
                    break;
                }
            }
        }else flag = false;
        (flag) ? (cout << "YES\n") : (cout << "NO\n");
    }
	return 0;
}


#include<iostream>
using namespace std;

int main()
{
    int m;
    cin>>m;
    for(int i=0;i<m;i++){
    int n,x,flag=0;
    cin>>n;
    int a[n];
    for(int i=0;i<n;i++)
    {
        cin>>a[i];
        if(a[i]==1)
        {
             x=i;
        }
    }
    for(int j=0;j<n-1 ;j++)
    {
        if(a[(x+j+1)%n]==a[(x+j)%n]+1)
        {
            continue;
        }
        else if(a[(x+j+1)%n]==a[(x+j)%n]-1)
        {
            continue;
        }
         else if(a[(x+j+1)%n]==n)
        {
            continue;
        }
        else{
            flag=1;break;
        }
    }
    if(flag==0)
    {
        cout<<"YES"<<endl;
    }
    else{
        cout<<"NO"<<endl;
    }
    }
}


#include<bits/stdc++.h>
using namespace std;
int q;
int main()
{	cin>>q;
	while(q--)
	{
		int n,a[210],flag=1,x;
		cin>>n;
		for(int i=0;i<n;++i)
		{
		    cin>>a[i];
		    if(a[i]==1)
		        x=i;
		}
		for(int i=x;i<x+n;++i)
			if(a[i%n]!=i-x+1)
			{
				flag=0;
			    break;
			}
		if(flag)
		{
			cout<<"YES"<<endl;
			continue;
		}
		flag=1;
		for(int i=x+n;i>x;--i)
			if(a[i%n]!=x+n-i+1)
			{
				flag=0;
			    break;
			}
		if(flag)
			cout<<"YES"<<endl;
		else
			cout<<"NO"<<endl;
	}
	return 0;
}


#include<iostream>
using namespace std;

int main()
{
    int m;
    cin>>m;
    for(int i=0;i<m;i++){
    int n,x,flag=0;
    cin>>n;
    int a[n];
    for(int i=0;i<n;i++)
    {
        cin>>a[i];
        if(a[i]==1)
        {
             x=i;
        }
    }
    for(int j=x;j<x+n ;j++)
    {
        if(a[(j+1)%n]==a[j%n]+1)
        {
            continue;
        }

     else{
            flag=1;break;}

    }
    if(flag==0)
    {
        cout<<"YES"<<endl;
        continue;
    }

flag=0;

      for(int j=x+n;j<x;j--)    {
        if(a[j%n]==a[(j-x)%n]+1)
        {
            continue;
        }

        else{
            flag=1;break;
        }
    }
    if(flag==0)
    {
        cout<<"YES"<<endl;
    }
    else{
        cout<<"NO"<<endl;
    }
    }
}


#include<iostream>
using namespace std;

int main()
{
    int m;
    cin>>m;
    for(int i=0;i<m;i++){
    int n,x,flag=0;
    cin>>n;
    int a[n];
    for(int i=0;i<n;i++)
    {
        cin>>a[i];
        if(a[i]==1)
        {
             x=i;
        }
    }
    for(int j=x;j<x+n ;j++)
    {
        if(a[(j+1)%n]==a[j%n]+1)
        {
            continue;
        }

     else{
            flag=1;break;}

    }
    if(flag==0)
    {
        cout<<"YES"<<endl;
        continue;
    }

flag=0;

      for(int j=x;j<x+n ;j++)
    {
        if(a[(j-1)%n]==a[j%n]+1)
        {
            continue;
        }

        else{
            flag=1;break;
        }
    }
    if(flag==0)
    {
        cout<<"YES"<<endl;
    }
    else{
        cout<<"NO"<<endl;
    }
    }
}


#include<iostream>
using namespace std;

int main()
{
    int n,x,flag=0;
    cin>>n;
    int a[n];
    for(int i=0;i<n;i++)
    {
        cin>>a[i];
        if(a[i]==1)
        {
             x=i;
        }
    }
    for(int j=0;j<n-1 ;j++)
    {
        if(a[(x+j+1)%n]==a[(x+j)%n]+1)
        {
            continue;
        }
        else if(a[(x+j+1)%n]==a[(x+j)%n]-1)
        {
            continue;
        }
        else{
            flag=1;break;
        }
    }
    if(flag==0)
    {
        cout<<"YES"<<endl;
    }
    else{
        cout<<"NO"<<endl;
    }

}


#include<iostream>
using namespace std;
int main()
{
 int n,m;
 cin>>n;
 for(int i=0;i<n;i++)
 {
     cin>>m;
     int a[m],flag=0;
        int z=a[i];
     for(i=0;i<m;i++)
     {
         cin>>a[i];
     }
      for(i=0;i<m-1;i++)
     {
         if(a[i+1]==a[i]+1)
         {
             continue;
         }
         else if(a[m-1]==m-i && a[0]==1)
         {
             continue;
         }

          if((a[i+1]==z-1 || a[i+1]==m) || (a[i+1]==z+1 || a[i+1]==1))
            {

            continue;
         }
         else{flag=1;break;}
     }
     if(flag==0)
     {
         cout<<"YES"<<endl;
     }
     else
     {
         cout<<"NO"<<endl;
     }
 }
}


#include<bits/stdc++.h>
using namespace std;
main(){
    int q;
    cin>>q;
    while(q--){
        int n;
        cin>>n;
        int a[n];
        int i=-1;
        while(++i<n)cin>>a[i];
        i=0;
        int ct=0,cki=0,ckd=0;
        while(++i<n){
            if(a[i]>a[i-1]&&cki==0)ct++,cki=1;
            if(a[i]<a[i-1]&&ckd==0)ct++,ckd=1;
            if(ct==2)break;
        }
        if(i==n){
            cout<<"YES"<<endl;
            continue;
        }
        cki=0,ckd=0;
        while(++i<n){
            if(a[i]>a[i-1]&&cki==0)cki=1;
            if(a[i]<a[i-1]&&ckd==0)ckd=1;
            if(cki==1&&cd==1)break;
        }
        if(i!=n){
            cout<<"NO"<<endl;
            continue;
        }
        if(cki==0&&ckd==0){
            if(a[n-2]>a[n-1]&&a[0]>a[n-1]){
                cout<<"YES"<<endl;
                continue;
            }
            else if(a[n-2]<a[n-1]&&a[0]<a[n-1]){
                cout<<"YES"<<endl;
                continue;
            }
            else{
                cout<<"NO"<<endl;
                continue;
            }
        }
        if(a[n-2]>a[n-1]&&a[0]<a[n-1]){
            cout<<"YES"<<endl;
            continue;
        }
        else if(a[n-2]<a[n-1]&&a[0]>a[n-1]){
            cout<<"YES"<<endl;
            continue;
        }
        else{
            cout<<"NO"<<endl;
            continue;
        }
    }
    return 0;
}


#include<bits/stdc++.h>
using namespace std;
main(){
    int q;
    cin>>q;
    while(q--){
        int n;
        cin>>n;
        int a[n];
        int i=-1,j;
        while(++i<n)cin>>a[i];
        i=-1;
        while(++i<n){
            j=i+1;
            int cki=0,ckd=0;
            while(1){
                if(i==0&&j==n)break;
                if(j==n){
                    if(a[0]>a[n-1]&&cki==0)cki=1;
                    if(a[0]<a[n-1]&&ckd==0)ckd=1;
                    j=1;
                }
                if(j==i)break;
                if(a[j]>a[j-1]&&cki==0)cki=1;
                if(a[j]<a[j-1]&&ckd==0)ckd=1;
                j++;
            }
            if((cki==1&&ckd==0)||(cki==0&&ckd==1)||cki==0&&ckd==0){
                cout<<"YES"<<endl;
                break;
            }
        }
        if(i==n)cout<<"NO"<<endl;
    }
    return 0;
}


#include<bits/stdc++.h>
using namespace std;
main(){
    int q;
    cin>>q;
    while(q--){
        int n;
        cin>>n;
        int a[n];
        int i=-1,j;
        while(++i<n)cin>>a[i];
        i=-1;
        while(++i<n){
            j=i+1;
            int cki=0,ckd=0;
            while(1){
                if(i==0&&j==n)break;
                if(j==n){
                    if(a[0]>a[n-1]&&cki==0)cki=1;
                    if(a[0]<a[n-1]&&ckd==0)ckd=1;
                    j=1;
                }
                if(j==i)break;
                if(a[j]>a[j-1]&&cki==0)cki=1;
                if(a[j]<a[j-1]&&ckd==0)ckd=1;
                j++;
            }
            if((cki==1&&ckd==0)||(cki==0&&ckd==1)){
                cout<<"YES"<<endl;
                break;
            }
        }
        if(i==n)cout<<"NO"<<endl;
    }
    return 0;
}


#include<bits/stdc++.h>
using namespace std;
main(){
    int q;
    cin>>q;
    while(q--){
        int n;
        cin>>n;
        int a[n];
        int i=-1;
        while(++i<n)cin>>a[i];
        i=0;
        int ct=0,cki=0,ckd=0;
        while(++i<n){
            if(a[i]>a[i-1]&&cki==0)ct++,cki=1;
            if(a[i]<a[i-1]&&ckd==0)ct++,ckd=1;
            if(ct==2)break;
        }
        if(i==n){
            cout<<"YES"<<endl;
            continue;
        }
        cki=0,ckd=0;
        while(++i<n){
            if(a[i]>a[i-1]&&cki==0)cki=1;
            if(a[i]<a[i-1]&&ckd==0)ckd=1;
            if(cki==1&&ckd==1)break;
        }
        if(i!=n){
            cout<<"NO"<<endl;
            continue;
        }
        if(cki==0&&ckd==0){
            if(n==3){
                cout<<"YES"<<endl;
                continue;
            }
            if(a[n-2]>a[n-1]&&a[0]>a[n-1]){
                cout<<"YES"<<endl;
                continue;
            }
            else if(a[n-2]<a[n-1]&&a[0]<a[n-1]){
                cout<<"YES"<<endl;
                continue;
            }
            else{
                cout<<"NO"<<endl;
                continue;
            }
        }
        if(a[n-2]>a[n-1]&&a[0]<a[n-1]){
            cout<<"YES"<<endl;
            continue;
        }
        else if(a[n-2]<a[n-1]&&a[0]>a[n-1]){
            cout<<"YES"<<endl;
            continue;
        }
        else{
            cout<<"NO"<<endl;
            continue;
        }
    }
    return 0;
}


#include<bits/stdc++.h>
using namespace std;
main(){
    int q;
    cin>>q;
    while(q--){
        int n;
        cin>>n;
        int a[n];
        int i=-1;
        while(++i<n)cin>>a[i];
        i=0;
        int ct=0,cki=0,ckd=0;
        while(++i<n){
            if(a[i]>a[i-1]&&cki==0)ct++,cki=1;
            if(a[i]<a[i-1]&&ckd==0)ct++,ckd=1;
            if(ct==2)break;
        }
        if(i==n){
            cout<<"YES"<<endl;
            continue;
        }
        cki=0,ckd=0;
        while(++i<n){
            if(a[i]>a[i-1]&&cki==0)cki=1;
            if(a[i]<a[i-1]&&ckd==0)ckd=1;
            if(cki==1&&ckd==1)break;
        }
        if(i!=n){
            cout<<"NO"<<endl;
            continue;
        }
        if(cki==0&&ckd==0){
            if(a[n-2]>a[n-1]&&a[0]>a[n-1]){
                cout<<"YES"<<endl;
                continue;
            }
            else if(a[n-2]<a[n-1]&&a[0]<a[n-1]){
                cout<<"YES"<<endl;
                continue;
            }
            else{
                cout<<"NO"<<endl;
                continue;
            }
        }
        if(a[n-2]>a[n-1]&&a[0]<a[n-1]){
            cout<<"YES"<<endl;
            continue;
        }
        else if(a[n-2]<a[n-1]&&a[0]>a[n-1]){
            cout<<"YES"<<endl;
            continue;
        }
        else{
            cout<<"NO"<<endl;
            continue;
        }
    }
    return 0;
}


#include<bits/stdc++.h>
using namespace std;
main(){
    int q;
    cin>>q;
    while(q--){
        int n;
        cin>>n;
        int a[n];
        int i=-1,j;
        while(++i<n)cin>>a[i];
        i=-1;
        while(++i<n){
            j=i+1;
            int cki=0,ckd=0;
            while(1){
                if(j==n){
                    if(a[0]>a[n-1]&&cki==0)cki=1;
                    if(a[0]<a[n-1]&&ckd==0)ckd=1;
                    j=1;
                }
                if(j==i)break;
                if(a[j]>a[j-1]&&cki==0)cki=1;
                if(a[j]<a[j-1]&&ckd==0)ckd=1;
                j++;
            }
            if((cki==1&&ckd==0)||(cki==0&&ckd==1)){
                cout<<"YES"<<endl;
                break;
            }
        }
        if(i==n)cout<<"NO"<<endl;
    }
    return 0;
}


#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
int main() {
	int t;
	int n;
	int a[205];
	scanf("%d",&t);
	while(t--) {
		bool f=true;
		scanf("%d",&n);
		for(int i=0;i<n;i++) {
			scanf("%d",&a[i]);
		}

			if(a[1]==a[0]+1) {
				for(int j=1;j<n;j++) {
					if(a[j]!=a[j-1]+1) {
						f=false;
						break;
					}
					if(a[j]==n) a[j]=0;
				}
			}
			else {
			for(int k=0;k<n;k++) {
				if(a[k]==1 && k+1<n) {
					if(a[k+1]!=n) {
						f=false;
						break;
					}
					k++;
				}
				else {
					if(k!=0) {
					if(a[k]!=a[k-1]-1) {
						f=false;
						break;
					}
				}
				else {
					if(a[k+1]!=a[k]-1) {
						f=false;
						break;
					}
				}
				}
			}
		}
		if(f) printf("YES\n");
		else printf("NO\n");
	}
	return 0;
}


#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
int main() {
	int t;
	int n;
	int a[205];
	scanf("%d",&t);
	while(t--) {
		bool f=true;
		scanf("%d",&n);
		for(int i=0;i<n;i++) {
			scanf("%d",&a[i]);
		}
			if(a[0]==n && a[1]==1) {
				a[0]=0;
					for(int j=1;j<n;j++) {
					if(a[j]!=a[j-1]+1) {
						f=false;
						break;
					}
					if(a[j]==n) a[j]=0;
				}
				if(f) printf("YES\n");
			else printf("NO\n");
			continue;
			}
			if(a[1]==a[0]+1) {
				for(int j=1;j<n;j++) {
					if(a[j]!=a[j-1]+1) {
						f=false;
						break;
					}
					if(a[j]==n) a[j]=0;
				}
			}
			else {
			for(int k=0;k<n;k++) {
				if(a[k]==1 && k+1<n) {
					if(a[k+1]!=n) {
						f=false;
						break;
					}
					k++;
				}
				else {
					if(k!=0) {
					if(a[k]!=a[k-1]-1) {
						f=false;
						break;
					}
				}
				else {
					if(a[k+1]!=a[k]-1) {
						f=false;
						break;
					}
				}
				}
			}
		}
		if(f) printf("YES\n");
		else printf("NO\n");
	}
	return 0;
}


#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
int main() {
	int t;
	int n;
	int a[205];
	scanf("%d",&t);
	while(t--) {
		bool f=true;
		scanf("%d",&n);
		for(int i=0;i<n;i++) {
			scanf("%d",&a[i]);
		}
		if(n==1) {
			printf("YES\n");
			continue;
		}
			if(a[0]==n && a[1]==1) {
				a[0]=0;
					for(int j=1;j<n;j++) {
					if(a[j]!=a[j-1]+1) {
						f=false;
						break;
					}
					if(a[j]==n) a[j]=0;
				}
				if(f) printf("YES\n");
			else printf("NO\n");
			continue;
			}

			if(a[1]==a[0]+1) {
				for(int j=1;j<n;j++) {
					if(a[j]!=a[j-1]+1) {
						f=false;
						break;
					}
					if(a[j]==n) a[j]=0;
				}
			}
			else {
			for(int k=0;k<n;k++) {
				if(a[k]==1 && k+1<n) {
					if(a[k+1]!=n) {
						f=false;
						break;
					}
					k++;
				}
				else {
					if(k!=0) {
					if(a[k]!=a[k-1]-1) {
						f=false;
						break;
					}
				}
				else {
					if(a[k+1]!=a[k]-1) {
						f=false;
						break;
					}
				}
				}
			}
		}
		if(f) printf("YES\n");
		else printf("NO\n");
	}
	return 0;
}


#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
int main() {
	int t;
	int n;
	int a[205];
	scanf("%d",&t);
	while(t--) {
		bool f=true;
		scanf("%d",&n);
		for(int i=0;i<n;i++) {
			scanf("%d",&a[i]);
		}
		for(int i=1;i<n;i++) {
			if(a[i]==a[i-1]+1) {
				for(int i=1;i<n;i++) {
					if(a[i]!=a[i-1]+1) {
						f=false;
						break;
					}
				}
			}
			else {
			for(int i=0;i<n;i++) {
				if(a[i]==1 && i+1<n) {
					if(a[i+1]!=n) {
						f=false;
						break;
					}
					i++;
				}
				else {
					if(i!=0) {
					if(a[i]!=a[i-1]-1) {
						f=false;
						break;
					}
				}
				else {
					if(a[i+1]!=a[i]-1) {
						f=false;
						break;
					}
				}
				}
			}
			}
		}
		if(f) printf("YES\n");
		else printf("NO\n");
	}
	return 0;
}


#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
int main() {
	int t;
	int n;
	int a[205];
	scanf("%d",&t);
	while(t--) {
		bool f=true;
		scanf("%d",&n);
		for(int i=0;i<n;i++) {
			scanf("%d",&a[i]);
		}
		for(int i=1;i<n;i++) {
			if(a[i]==a[i-1]+1) {
				for(int i=1;i<n;i++) {
					if(a[i]!=a[i-1]+1) {
						f=false;
						break;
					}
				}
			}
			else {
			for(int i=0;i<n;i++) {
				if(a[i]==1) {
					if(a[i+1]!=n) {
						f=false;
						break;
					}
					i++;
				}
				else {
					if(i!=0) {
					if(a[i]!=a[i-1]-1) {
						f=false;
						break;
					}
				}
				else {
					if(a[i+1]!=a[i]-1) {
						f=false;
						break;
					}
				}
				}
			}
			}
		}
		if(f) printf("YES\n");
		else printf("NO\n");
	}
	return 0;
}


#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
int main() {
	int t;
	int n;
	int a[205];
	scanf("%d",&t);
	while(t--) {
		bool f=true;
		scanf("%d",&n);
		for(int i=0;i<n;i++) {
			scanf("%d",&a[i]);
		}
			if(a[0]==n && a[1]==1) {
				a[0]=0;
					for(int j=1;j<n;j++) {
					if(a[j]!=a[j-1]+1) {
						f=false;
						break;
					}
					if(a[j]==n) a[j]=0;
				}
				if(f) printf("YES\n");
			else printf("NO\n");
			continue;
			}

			if(a[1]==a[0]+1) {
				for(int j=1;j<n;j++) {
					if(a[j]!=a[j-1]+1) {
						f=false;
						break;
					}
					if(a[j]==n) a[j]=0;
				}
			}
			else {
			for(int k=0;k<n;k++) {
				if(a[k]==1 && k+1<n) {
					if(a[k+1]!=n) {
						f=false;
						break;
					}
					k++;
				}
				else {
					if(k!=0) {
					if(a[k]!=a[k-1]-1) {
						f=false;
						break;
					}
				}
				else {
					if(a[k+1]!=a[k]-1) {
						f=false;
						break;
					}
				}
				}
			}
		}
		if(f) printf("YES\n");
		else printf("NO\n");
	}
	return 0;
}


#include<bits/stdc++.h>
using namespace std;
#define int long long
int max(int a,int b){
    if(a>b){
        return a;
    }
    return b;
}
int min(int a,int b){
    if(a<b){
        return a;
    }
    return b;
}
#define pb push_back
#define mpp make_pair
int32_t main(){
    int t;
    cin>>t;
    while(t--){
        int n;
        cin>>n;
        if(n==1){
            cout<<"YES"<<endl;
            continue;
        }
        int arr[n];
        int j=0,k=1;
        for(int i=0;i<n;i++){
            cin>>arr[i];
            if(arr[i]==1){
                j=i;
            }
        }
        int c=0,p,flag=0;
        if(arr[(j+1)%n]==n){
            c=0;
            p=n;
        }
        else if(arr[(j+1)%n]==2){
            c=1;
            p=2;
        }
        else{
            flag=1;
        }
        j++;
        j=j%n;
        while(k<n){
            if(c==1){
                if(arr[j%n]!=p){
                    flag=1;
                }
                p++;
                k++;
                j++;
            }
            else{
                if(arr[j%n]!=p){
                    flag=1;
                }
                p--;
                k++;
                j++;
            }

        }
        if(flag==1){
            cout<<"NO"<<endl;
        }
        else{
            cout<<"YES"<<endl;
        }

    }
}


By jaane_tu_ya_jaane_na, contest: Codeforces Round #579 (Div. 3), problem: (A) Circle of Students, In queue, #
 #include<bits/stdc++.h>
using namespace std;
#define int long long
int max(int a,int b){
    if(a>b){
        return a;
    }
    return b;
}
int min(int a,int b){
    if(a<b){
        return a;
    }
    return b;
}
#define pb push_back
#define mpp make_pair
int32_t main(){
    int t;
    cin>>t;
    while(t--){
        int n;
        cin>>n;
        if(n==1){
            cout<<"YES"<<endl;
            continue;
        }
        int arr[n];
        int j=0,k=1;
        for(int i=0;i<n;i++){
            cin>>arr[i];
            if(arr[i]==1){
                j=i;
            }
        }
        int c=0,p,flag=0;
        if(arr[(j+1)%n]==n){
            c=0;
            p=n;
        }
        else if(arr[(j+1)%n]==2){
            c=1;
            p=2;
        }
        else{
            flag=1;
        }
        j++;
        while(k<n){
            if(c==1){
                if(arr[j%n]!=p){
                    flag=1;
                }
                p++;
                k++;
                j++;
            }
            else{
                if(arr[j%n]!=p){
                    flag=1;
                }
                p--;
                k++;
                j++;
            }

        }
        if(flag==1){
            cout<<"NO"<<endl;
        }
        else{
            cout<<"YES"<<endl;
        }

    }


#include<bits/stdc++.h>
using namespace std;
#define int long long
int max(int a,int b){
    if(a>b){
        return a;
    }
    return b;
}
int min(int a,int b){
    if(a<b){
        return a;
    }
    return b;
}
#define pb push_back
#define mpp make_pair
int32_t main(){
    int t;
    cin>>t;
    while(t--){
        int n;
        cin>>n;
        if(n==1){
            cout<<"YES"<<endl;
            continue;
        }
        int arr[n];
        for(int i=0;i<n;i++){
            cin>>arr[i];
        }
        int flag=0,c=0;
        int j=0,k=0;
        for(int i=0;i<n;i++){
            if(arr[i]==1 || arr[i]==n){
                if(abs(arr[(i+1)%n]-arr[i])==n-1 && abs(arr[(i-1)%n]-arr[i])==1){
                    flag=0;
                }
                else if((abs(arr[(i+1)%n]-arr[i])==1 && abs(arr[(i-1)%n]-arr[i])==n-1)){
                    flag=0;
                }
                else{
                    flag=1;
                }
            }
            else{
                if(abs(arr[(i+1)%n]-arr[i])==1  && abs(arr[(i-1)%n]-arr[i])==1){
                    flag=0;
                }
                else{
                    flag=1;
                }
            }
        }
        if(flag==1){
            cout<<"NO"<<endl;
        }
        else{
            cout<<"YES"<<endl;
        }

    }
}


#include<bits/stdc++.h>
using namespace std;
#define int long long
int max(int a,int b){
    if(a>b){
        return a;
    }
    return b;
}
int min(int a,int b){
    if(a<b){
        return a;
    }
    return b;
}
#define pb push_back
#define mpp make_pair
int32_t main(){
    int t;
    cin>>t;
    while(t--){
        int n;
        cin>>n;
        if(n==1){
            cout<<"YES"<<endl;
            continue;
        }
        int arr[n];
        int j=0,k=1;
        for(int i=0;i<n;i++){
            cin>>arr[i];
            if(arr[i]==1){
                j=i;
            }
        }
        int c=0,p,flag=0;
        if(arr[(j+1)%n]==n){
            c=0;
            p=n;
        }
        else if(arr[(j+1)%n]==2){
            c=1;
            p=2;
        }
        else{
            flag=1;
        }
        j++;
        while(k<n){
            if(c==1){
                if(arr[j%n]!=p){
                    flag=1;
                }
                p++;
                k++;
                j++;
            }
            else{
                if(arr[j%n]!=p){
                    flag=1;
                }
                p--;
                k++;
                j++;
            }

        }
        if(flag==1){
            cout<<"NO"<<endl;
        }
        else{
            cout<<"YES"<<endl;
        }

    }
}


#include<bits/stdc++.h>
using namespace std;
#define int long long
int max(int a,int b){
    if(a>b){
        return a;
    }
    return b;
}
int min(int a,int b){
    if(a<b){
        return a;
    }
    return b;
}
#define pb push_back
#define mpp make_pair
int32_t main(){
    int t;
    cin>>t;
    while(t--){
        int n;
        cin>>n;
        if(n==1){
            cout<<"YES"<<endl;
            continue;
        }
        int arr[n];
        for(int i=0;i<n;i++){
            cin>>arr[i];
        }
        map<int,int>m;
        for(int i=0;i<n;i++){
            m[abs(arr[i]-arr[(i+1)%n])]++;
        }
        if(m.size()!=2){
            cout<<"NO"<<endl;
        }
        else if(n==2 && m[1]==2){
            cout<<"YES"<<endl;
        }
        else if(m[1]==n-1 && m[n-1]==1){
            cout<<"YES"<<endl;
        }
        else{
            cout<<"NO"<<endl;
        }

    }
}


#include<bits/stdc++.h>
using namespace std;
int main(){
    int t;
    cin>>t;
    while(t--){
        int n;
        cin>>n;
        int arr[n];
        int j=0,flag=0,temp=0,k=0,p=0;
        int cnt[1000]={0};
        for(int i=0;i<n;i++){
            cin>>arr[i];
            if(cnt[arr[i]]!=0){
                flag=1;
            }
            else{
                cnt[arr[i]]=1;
            }
            if(arr[i]==1){
                j=i;
            }
        }
        int c=0;
        if(arr[(j+1)%n]==2){
            c=1;
            p=2;
        }
        else if(arr[(j+1)%n]==n){
            p=n;
        }
        else{
            flag=1;
        }
        k=k+1;
        j++;
        while(k<n && p>0){
            //cout<<j<<" "<<k<<endl;
            if(c==1){
                if(arr[j%n]!=p){
                    flag=1;
                }
                p++;
                j++;
                k++;
            }
            else{
                if(arr[j%n]!=p){
                    flag=1;
                }
                p--;
                j++;
                k++;
            }
        }
        if(flag==1){
            cout<<"NO"<<endl;
        }
        else{
            cout<<"YES"<<endl;
        }
    }
}


#include<bits/stdc++.h>
using namespace std;
#define int long long
int max(int a,int b){
    if(a>b){
        return a;
    }
    return b;
}
int min(int a,int b){
    if(a<b){
        return a;
    }
    return b;
}
#define pb push_back
#define mpp make_pair
int32_t main(){
    int t;
    cin>>t;
    while(t--){
        int n;
        cin>>n;
        if(n==1){
            cout<<"YES"<<endl;
            continue;
        }
        int arr[n];
        int j=0,k=1;
        for(int i=0;i<n;i++){
            cin>>arr[i];
            if(arr[i]==1){
                j=i;
            }
        }
        int c=0,p,flag=0;
        if(arr[(j+1)%n]==n){
            c=0;
            p=n;
        }
        else if(arr[(j+1)%n]==2){
            c=1;
            p=2;
        }
        j++;
        while(k<n){
            if(c==1){
                if(arr[j%n]!=p){
                    flag=1;
                }
                p++;
                k++;
                j++;
            }
            else{
                if(arr[j%n]!=p){
                    flag=1;
                }
                p--;
                k++;
                j++;
            }

        }
        if(flag==1){
            cout<<"NO"<<endl;
        }
        else{
            cout<<"YES"<<endl;
        }

    }
}


#include<iostream>
#include<cctype>
using namespace std;
int indexofSmallestElement(int array[], int size)
{
    int index = 0;

    for(int i = 1; i < size; i++)
    {
        if(array[i] < array[index])
            index = i;
    }

    return index;
}

int main()
{
	int q;
	cin>>q;
	for(int i=0;i<q;i++)
	{
		int n;
		cin>>n;
		int a[n];
		for(int j=0;j<n;j++)
		{	cin>>a[j];
		}
		int j=indexofSmallestElement(a,n);

		if(a[j+1]==2)
		{	int p=2,m=n;
			int ml=0,ql=0;
			for(int t=j+1;t<n;t++)
			{	if(a[t]==p)
					ml++;
				p++;
			}
			for(int t=j-1;t>=0;t--)
			{	if(a[t]==m)
					ql++;
				m--;

			}
			if((ml+ql)==(n-1))
				cout<<"YES"<<endl;
			else
				cout<<"NO"<<endl;

		}

		else if(a[j-1]==2)
		{	int p=2,m=n;
			int ml=0,ql=0;
			for(int t=j+1;t<n;t++)
			{	if(a[t]==m)
					ml++;
				m--;
			}
			for(int t=j-1;t>=0;t--)
			{	if(a[t]==p)
					ql++;
				p++;

			}

			if((ml+ql)==(n-1))
				cout<<"YES"<<endl;
			else
				cout<<"NO"<<endl;

		}
		else if(n==1)
		{	if(a[0]==1)
				cout<<"YES";
			else
				cout<<"NO";
		}
		else if(j==0)
		{	int m=n;
			int ml=0;
			for(int t=j+1;t<n;t++)
			{	if(a[t]==m)
					ml++;
				m--;
			}
			if(ml==(n-1))
				cout<<"YES"<<endl;
			else
				cout<<"NO"<<endl;

		}

		else
			cout<<"NO"<<endl;
	}
}


#include<iostream>
#include<cctype>
using namespace std;
int indexofSmallestElement(int array[], int size)
{
    int index = 0;

    for(int i = 1; i < size; i++)
    {
        if(array[i] < array[index])
            index = i;
    }

    return index;
}

int main()
{
	int q;
	cin>>q;
	for(int i=0;i<q;i++)
	{
		int n;
		cin>>n;
		int a[n];
		for(int j=0;j<n;j++)
		{	cin>>a[j];
		}
		int j=indexofSmallestElement(a,n);

		if(a[j+1]==2)
		{	int p=2,m=n;
			int ml=0,ql=0;
			for(int t=j+1;t<n;t++)
			{	if(a[t]==p)
					ml++;
				p++;
			}
			for(int t=j-1;t>=0;t--)
			{	if(a[t]==m)
					ql++;
				m--;

			}
			if((ml+ql)==(n-1))
				cout<<"YES"<<endl;
			else
				cout<<"NO"<<endl;

		}

		else if(a[j-1]==2)
		{	int p=2,m=n;
			int ml=0,ql=0;
			for(int t=j+1;t<n;t++)
			{	if(a[t]==m)
					ml++;
				m--;
			}
			for(int t=j-1;t>=0;t--)
			{	if(a[t]==p)
					ql++;
				p++;

			}

			if((ml+ql)==(n-1))
				cout<<"YES"<<endl;
			else
				cout<<"NO"<<endl;

		}
		else if(n==1)
			cout<<"YES"<<endl;
		else if(j==0)
		{	int m=n;
			int ml=0;
			for(int t=j+1;t<n;t++)
			{	if(a[t]==m)
					ml++;
				m--;
			}
			if(ml==(n-1))
				cout<<"YES"<<endl;
			else
				cout<<"NO"<<endl;

		}

		else
			cout<<"NO"<<endl;
	}
}


#include<iostream>
#include<cctype>
using namespace std;
int indexofSmallestElement(int array[], int size)
{
    int index = 0;

    for(int i = 1; i < size; i++)
    {
        if(array[i] < array[index])
            index = i;
    }

    return index;
}

int main()
{
	int q;
	cin>>q;
	for(int i=0;i<q;i++)
	{
		int n;
		cin>>n;
		int a[n];
		for(int j=0;j<n;j++)
		{	cin>>a[j];
		}
		int j=indexofSmallestElement(a,n);

		if(a[(j+1) % n]==2)
		{	int p=2,m=n;
			int ml=0,ql=0;
			for(int t=j+1;t<n;t++)
			{	if(a[t]==p)
					ml++;
				p++;
			}
			for(int t=j-1;t>=0;t--)
			{	if(a[t]==m)
					ql++;
				m--;

			}
			if((ml+ql)==(n-1))
				cout<<"YES"<<endl;
			else
				cout<<"NO"<<endl;

		}
		else if(a[j-1]==2)
		{	int p=2,m=n;
			int ml=0,ql=0;
			for(int t=j+1;t<n;t++)
			{	if(a[t]==m)
					ml++;
				m--;
			}
			for(int t=j-1;t>=0;t--)
			{	if(a[t]==p)
					ql++;
				p++;

			}

			if((ml+ql)==(n-1))
				cout<<"YES"<<endl;
			else
				cout<<"NO"<<endl;

		}
		else if(n==1)
		{	if(a[0]==1)
				cout<<"YES"<<endl;
			else
				cout<<"NO"<<endl;
		}
		else if(j==0)
		{	int m=n;
			int ml=0;
			for(int t=j+1;t<n;t++)
			{	if(a[t]==m)
					ml++;
				m--;
			}
			if(ml==(n-1))
				cout<<"YES"<<endl;
			else
				cout<<"NO"<<endl;

		}

		else
			cout<<"NO"<<endl;
	}
}


#include<iostream>
#include<cctype>
using namespace std;
int indexofSmallestElement(int array[], int size)
{
    int index = 0;

    for(int i = 1; i < size; i++)
    {
        if(array[i] < array[index])
            index = i;
    }

    return index;
}

int main()
{
	int q;
	cin>>q;
	for(int i=0;i<q;i++)
	{
		int n;
		cin>>n;
		int a[n];
		for(int j=0;j<n;j++)
		{	cin>>a[j];
		}
		int j=indexofSmallestElement(a,n);

		if(a[j+1]==2)
		{	int p=2,m=n;
			int ml=0,ql=0;
			for(int t=j+1;t<n;t++)
			{	if(a[t]==p)
					ml++;
				p++;
			}
			for(int t=j-1;t>=0;t--)
			{	if(a[t]==m)
					ql++;
				m--;

			}
			if((ml+ql)==(n-1))
				cout<<"YES"<<endl;
			else
				cout<<"NO"<<endl;

		}

		else if(a[j-1]==2)
		{	int p=2,m=n;
			int ml=0,ql=0;
			for(int t=j+1;t<n;t++)
			{	if(a[t]==m)
					ml++;
				m--;
			}
			for(int t=j-1;t>=0;t--)
			{	if(a[t]==p)
					ql++;
				p++;

			}

			if((ml+ql)==(n-1))
				cout<<"YES"<<endl;
			else
				cout<<"NO"<<endl;

		}
		else if(n==1)
		{	if(a[0]==1)
				cout<<"YES"<<endl;
			else
				cout<<"NO"<<endl;
		}
		else if(j==0)
		{	int m=n;
			int ml=0;
			for(int t=j+1;t<n;t++)
			{	if(a[t]==m)
					ml++;
				m--;
			}
			if(ml==(n-1))
				cout<<"YES"<<endl;
			else
				cout<<"NO"<<endl;

		}

		else
			cout<<"NO"<<endl;
	}
}


#include <bits/stdc++.h>

#define inf 0x3f3f3f3f

#define MOD 1000000007

#define pb push_back

#define sq(x) ((x)*(x))

#define x first

#define y second

#define eps 1e-8

#define bpt(x) (__builtin_popcount(x))

#define bptl(x) (__builtin_popcountll(x))

#define bit(x, y) (((x)>>(y))&1)

#define bclz(x) (__builtin_clz(x))

#define bclzl(x) (__builtin_clzll(x))

#define bctz(x) (__builtin_ctz(x))

#define bctzl(x) (__builtin_ctzll(x))

#define debug(x) cout << #x << " = " << x << endl

using namespace std;

typedef long long INT;

typedef vector<int> VI;

typedef pair<int, int> pii;

typedef pair<pii, int> pi3;

typedef double DO;

template<typename T, typename U> inline void smin(T &a, U b) {if (a>b) a=b;}

template<typename T, typename U> inline void smax(T &a, U b) {if (a<b) a=b;}

#define NN 100100

VI adj[NN];

int cnt[NN];

INT sum[NN];

void dfs(int u, int fa=0, int dp=0){

	cnt[dp]++;

	for(int i=adj[u].size(); i--; ){

		int v=adj[u][i];

		if(v==fa) continue;

		dfs(v, u, dp+1);

	}

}

int main() {

	int n, k, p, u, v;

	cin >> n >> k >> p;

	for(int i=1; i<n; i++){

		scanf("%d %d", &u, &v);

		adj[u].pb(v);

		adj[v].pb(u);

	}

	dfs(1);

	cnt[0]=0;

	for(int i=1; i<n; i++) sum[i]=sum[i-1]+(INT)cnt[i]*(n-i), cnt[i]+=cnt[i-1];

	int ans=0;

	for(int i=1; i<n; i++){

		int st=0, ed=i, mid;

		while(ed-st>1){

			mid=st+ed>>1;

			if(sum[i]-sum[mid-1]-(INT)(cnt[i]-cnt[mid-1])*(n-i)>p) st=mid;

			else ed=mid;

		}

		smax(ans, (int)(cnt[i]-cnt[st]+min((int)(p-(sum[i]-sum[st]-(cnt[i]-cnt[st])*(n-i)))/(i-st), cnt[st])));

	}

	cout << min(ans, k) << endl;

	return 0;

}


#include <bits/stdc++.h>

#define inf 0x3f3f3f3f

#define MOD 1000000007

#define pb push_back

#define bpt(x) (__builtin_popcount(x))

#define bclz(x) (__builtin_clz(x))

#define bctz(x) (__builtin_ctz(x))

#define bit(x, y) (((x)>>(y))&1)

using namespace std;

typedef long long INT;

typedef vector<int> VI;

typedef pair<int, int> pii;

typedef pair<pii, int> pi3;

typedef double DO;

template<class T, class U> inline void smin(T &a, U b) {if (a>b) a=b;}

template<class T, class U> inline void smax(T &a, U b) {if (a<b) a=b;}

template<class T> inline void gn(T &x) {char c,sg=0; while (c=getchar(), (c>'9' || c<'0') && c!='-' && c!=-1);if (c==-1) return ;if (c=='-') sg=1,c=getchar(); for (x=0; c>='0' && c<='9'; x=(x<<1)+(x<<3)+c-'0', c=getchar());if (sg) x=-x;}

template<class T> void print(T x) {if (x<0) return putchar('-'), print(-x);if (x<10) {putchar(x+'0');return ;} print(x/10);putchar(x%10+'0');}

template<class U, class V>inline void gn(U &u, V &v){gn(u);gn(v);}

template<class U, class V, class W>inline void gn(U &u, V &v, W &w){gn(u); gn(v, w);}

template<class T> void println(T &x) {print(x);putchar('\n');}

template<class T> void printsp(T &x) {print(x);putchar(' ');}

template<class U, class V> inline void print(U &u, V &v) {printsp(u);println(v);}

template<class U, class V, class W> inline void print(U &u, V &v, W &w){printsp(u);print(v, w);}

int power(int a, int b, int m=MOD, int ans=1) {

	for (; b; a=(INT)a*a%MOD,b>>=1) if (b&1) ans=(INT)ans*a%MOD;

	return ans;

}

#define NN 110101

INT sum[NN];

int deep[NN],cnt[NN],mx=0;

VI adj[NN];

void judge(int u,int fa=0){

	deep[u]=deep[fa]+1;

	cnt[deep[u]]++;

	smax(mx,deep[u]);

	for(int i=0;i<adj[u].size();i++){

		int v=adj[u][i];

		if(v==fa) continue;

		judge(v,u);

	}

}

int main() {

#ifndef ONLINE_JUDGE

	freopen("in.in", "r", stdin);

	freopen("out.out", "w", stdout);

#endif

	int n,k,p;

	gn(n,k,p);

	for(int i=0;i<n-1;i++){

		int u,v;

		gn(u,v);

		adj[u].push_back(v);

		adj[v].push_back(u);

	}

	judge(1);

	for(int i=2;i<=mx;i++) sum[i]=sum[i-1]+cnt[i];

	INT tmp=0;

	int ans=0;

	int cur=2;

	for(int i=2;i<=mx;i++){

		tmp+=sum[i-1]-sum[cur-1];

		while(p<tmp){

			tmp-=(INT) cnt[cur]*(INT)(i-cur);

			cur++;

		}

		int res=sum[i]-sum[cur-1];

		if(cur>2) res+=min((INT) cnt[cur-1],(p-tmp)/(i-cur+1));

		smax(ans,res);

	}

	printf("%d\n",min(k,ans));

	return 0;

}


#include <bits/stdc++.h>

#define inf 0x3f3f3f3f

#define MOD 1000000007

#define pb push_back

#define bpt(x) (__builtin_popcount(x))

#define bclz(x) (__builtin_clz(x))

#define bctz(x) (__builtin_ctz(x))

#define bit(x, y) (((x)>>(y))&1)

using namespace std;

typedef long long INT;

typedef vector<int> VI;

typedef pair<int, int> pii;

typedef pair<pii, int> pi3;

typedef double DO;

template<class T, class U> inline void smin(T &a, U b) {if (a>b) a=b;}

template<class T, class U> inline void smax(T &a, U b) {if (a<b) a=b;}

template<class T> inline void gn(T &x) {char c,sg=0; while (c=getchar(), (c>'9' || c<'0') && c!='-' && c!=-1);if (c==-1) return ;if (c=='-') sg=1,c=getchar(); for (x=0; c>='0' && c<='9'; x=(x<<1)+(x<<3)+c-'0', c=getchar());if (sg) x=-x;}

template<class T> void print(T x) {if (x<0) return putchar('-'), print(-x);if (x<10) {putchar(x+'0');return ;} print(x/10);putchar(x%10+'0');}

template<class U, class V>inline void gn(U &u, V &v){gn(u);gn(v);}

template<class U, class V, class W>inline void gn(U &u, V &v, W &w){gn(u); gn(v, w);}

template<class T> void println(T &x) {print(x);putchar('\n');}

template<class T> void printsp(T &x) {print(x);putchar(' ');}

template<class U, class V> inline void print(U &u, V &v) {printsp(u);println(v);}

template<class U, class V, class W> inline void print(U &u, V &v, W &w){printsp(u);print(v, w);}

int power(int a, int b, int m=MOD, int ans=1) {

	for (; b; a=(INT)a*a%MOD,b>>=1) if (b&1) ans=(INT)ans*a%MOD;

	return ans;

}

#define NN 110101

int vst[NN],id;

VI adj[NN];

void dfs(int u){

	vst[u]=++id;

	for(int i=0;i<adj[u].size();i++){

		int v=adj[u][i];

		if(vst[v]) continue;

		dfs(v);

	}

}

int main() {

#ifndef ONLINE_JUDGE

	freopen("in.in", "r", stdin);

	freopen("out.out", "w", stdout);

#endif

	int m,k,p;

	gn(m,k,p);

	for(int i=0;i<m-1;i++){

		int a,b;

		gn(a,b);

		adj[a].push_back(b);

		adj[b].push_back(a);

	}

	dfs(1);

	if(k<=adj[1].size()){

		printf("%d\n",k);

		return 0;

	}

	if(m-1<=k){

		printf("%d\n",m-1);

		return 0;

	}

	else{

		if(p>=k-adj[1].size()){

			printf("%d\n",k);

			return 0;

		}

	}

	return 0;

}


#include <bits/stdc++.h>

#define inf 0x3f3f3f3f

#define MOD 1000000007

#define pb push_back

#define sq(x) ((x)*(x))

#define x first

#define y second

#define eps 1e-8

#define bpt(x) (__builtin_popcount(x))

#define bptl(x) (__builtin_popcountll(x))

#define bit(x, y) (((x)>>(y))&1)

#define bclz(x) (__builtin_clz(x))

#define bclzl(x) (__builtin_clzll(x))

#define bctz(x) (__builtin_ctz(x))

#define bctzl(x) (__builtin_ctzll(x))

#define debug(x) cout << #x << " = " << x << endl

using namespace std;

typedef long long INT;

typedef vector<int> VI;

typedef pair<int, int> pii;

typedef pair<pii, int> pi3;

typedef double DO;

template<typename T, typename U> inline void smin(T &a, U b) {if (a>b) a=b;}

template<typename T, typename U> inline void smax(T &a, U b) {if (a<b) a=b;}

#define NN 100100

VI adj[NN];

int cnt[NN];

INT sum[NN];

void dfs(int u, int fa=0, int dp=0){

	cnt[dp]++;

	for(int i=adj[u].size(); i--; ){

		int v=adj[u][i];

		if(v==fa) continue;

		dfs(v, u, dp+1);

	}

}

int main() {

	int n, k, p, u, v;

	cin >> n >> k >> p;

	for(int i=1; i<n; i++){

		scanf("%d %d", &u, &v);

		adj[u].pb(v);

		adj[v].pb(u);

	}

	dfs(1);

	sum[0]=n*cnt[0];

	for(int i=1; i<n; i++) sum[i]=sum[i-1]+(INT)cnt[i]*(n-i), cnt[i]+=cnt[i-1];

	int ans=0;

	for(int i=1; i<n; i++){

		int st=0, ed=i, mid;

		while(ed-st>1){

			mid=st+ed>>1;

			if(sum[i]-sum[mid-1]-(cnt[i]-cnt[mid-1])*(n-i)>p) st=mid;

			else ed=mid;

		}

		if(!st) ans=max(ans, cnt[i]-cnt[st]);

		else ans=max(ans, (int)(cnt[i]-cnt[st]+min((int)(p-(sum[i]-sum[st]-(cnt[i]-cnt[st])*(n-i)))/(i-st), cnt[st])));

	}

	cout << min(ans, k) << endl;

	return 0;

}


#include <bits/stdc++.h>

#define inf 0x3f3f3f3f

#define MOD 1000000007

#define pb push_back

#define sq(x) ((x)*(x))

#define x first

#define y second

#define eps 1e-8

#define bpt(x) (__builtin_popcount(x))

#define bptl(x) (__builtin_popcountll(x))

#define bit(x, y) (((x)>>(y))&1)

#define bclz(x) (__builtin_clz(x))

#define bclzl(x) (__builtin_clzll(x))

#define bctz(x) (__builtin_ctz(x))

#define bctzl(x) (__builtin_ctzll(x))

#define debug(x) cout << #x << " = " << x << endl

using namespace std;

typedef long long INT;

typedef vector<int> VI;

typedef pair<int, int> pii;

typedef pair<pii, int> pi3;

typedef double DO;

template<typename T, typename U> inline void smin(T &a, U b) {if (a>b) a=b;}

template<typename T, typename U> inline void smax(T &a, U b) {if (a<b) a=b;}

#define NN 100100

VI adj[NN];

int cnt[NN];

INT sum[NN];

void dfs(int u, int fa=0, int dp=0){

	cnt[dp]++;

	for(int i=adj[u].size(); i--; ){

		int v=adj[u][i];

		if(v==fa) continue;

		dfs(v, u, dp+1);

	}

}

int main() {

	int n, k, p, u, v;

	cin >> n >> k >> p;

	for(int i=1; i<n; i++){

		scanf("%d %d", &u, &v);

		adj[u].pb(v);

		adj[v].pb(u);

	}

	dfs(1);

	sum[0]=n*cnt[0];

	for(int i=1; i<n; i++) sum[i]=sum[i-1]+(INT)cnt[i]*(n-i), cnt[i]+=cnt[i-1];

	int ans=0;

	for(int i=1; i<n; i++){

		int st=0, ed=i, mid;

		while(ed-st>1){

			mid=st+ed>>1;

			if(sum[i]-sum[mid-1]-(cnt[i]-cnt[mid-1])*(n-i)>p) st=mid;

			else ed=mid;

		}

		if(!st) ans=max(ans, cnt[i]-cnt[ed-1]);

		else ans=max(ans, (int)(cnt[i]-cnt[ed-1]+(p-(sum[i]-sum[ed-1]-(cnt[i]-cnt[ed-1])*(n-i)))/(i-st)));

	}

	cout << min(ans, k) << endl;

	return 0;

}


#include <bits/stdc++.h>

#define inf 0x3f3f3f3f

#define MOD 1000000007

#define pb push_back

#define bpt(x) (__builtin_popcount(x))

#define bclz(x) (__builtin_clz(x))

#define bctz(x) (__builtin_ctz(x))

#define bit(x, y) (((x)>>(y))&1)

using namespace std;

typedef long long INT;

typedef vector<int> VI;

typedef pair<int, int> pii;

typedef pair<pii, int> pi3;

typedef double DO;

template<class T, class U> inline void smin(T &a, U b) {if (a>b) a=b;}

template<class T, class U> inline void smax(T &a, U b) {if (a<b) a=b;}

template<class T> inline void gn(T &x) {char c,sg=0; while (c=getchar(), (c>'9' || c<'0') && c!='-' && c!=-1);if (c==-1) return ;if (c=='-') sg=1,c=getchar(); for (x=0; c>='0' && c<='9'; x=(x<<1)+(x<<3)+c-'0', c=getchar());if (sg) x=-x;}

template<class T> void print(T x) {if (x<0) return putchar('-'), print(-x);if (x<10) {putchar(x+'0');return ;} print(x/10);putchar(x%10+'0');}

template<class U, class V>inline void gn(U &u, V &v){gn(u);gn(v);}

template<class U, class V, class W>inline void gn(U &u, V &v, W &w){gn(u); gn(v, w);}

template<class T> void println(T &x) {print(x);putchar('\n');}

template<class T> void printsp(T &x) {print(x);putchar(' ');}

template<class U, class V> inline void print(U &u, V &v) {printsp(u);println(v);}

template<class U, class V, class W> inline void print(U &u, V &v, W &w){printsp(u);print(v, w);}

int power(int a, int b, int m=MOD, int ans=1) {

	for (; b; a=(INT)a*a%MOD,b>>=1) if (b&1) ans=(INT)ans*a%MOD;

	return ans;

}

#define NN 110101

int cnt[NN],deep[NN],mx;

 VI adj[NN];

 INT sum[NN];

void dfs(int u,int fa=0){

	deep[u]=deep[fa]+1;

	cnt[deep[u]]++;

	smax(mx,deep[u]);

	for(int i=0;i<adj[u].size();i++){

		int v=adj[u][i];

		if(v==fa) continue;

		dfs(v,u);

	}

}

int main() {

#ifndef ONLINE_JUDGE

	freopen("in.in", "r", stdin);

	freopen("out.out", "w", stdout);

#endif

	int m,k,p;

	gn(m,k,p);

	for(int i=0;i<m-1;i++){

		int a,b;

		gn(a,b);

		adj[a].push_back(b);

		adj[b].push_back(a);

	}

	dfs(1);

	INT tmp=0;

	int ans=0;

	for(int i=2;i<=mx;i++){

		sum[i]=sum[i-1]+cnt[i];

		int cur=2;

		tmp+=sum[i-1]-sum[cur-1];

		while(p<tmp){

			tmp-=(INT)cnt[cur]*(i-cur);

			cur++;

		}

		int res=sum[i]-sum[cur-1];

		if(cur>2) res+=min((INT)cnt[cur-1],(p-tmp)/(i-cur+1));

		smax(ans,res);

	}

	printf("%d\n",min(k,ans));

	return 0;

}


#include <bits/stdc++.h>

#define inf 0x3f3f3f3f

#define MOD 1000000007

#define pb push_back

#define bpt(x) (__builtin_popcount(x))

#define bclz(x) (__builtin_clz(x))

#define bctz(x) (__builtin_ctz(x))

#define bit(x, y) (((x)>>(y))&1)

using namespace std;

typedef long long INT;

typedef vector<int> VI;

typedef pair<int, int> pii;

typedef pair<pii, int> pi3;

typedef double DO;

template<class T, class U> inline void smin(T &a, U b) {if (a>b) a=b;}

template<class T, class U> inline void smax(T &a, U b) {if (a<b) a=b;}

template<class T> inline void gn(T &x) {char c,sg=0; while (c=getchar(), (c>'9' || c<'0') && c!='-' && c!=-1);if (c==-1) return ;if (c=='-') sg=1,c=getchar(); for (x=0; c>='0' && c<='9'; x=(x<<1)+(x<<3)+c-'0', c=getchar());if (sg) x=-x;}

template<class T> void print(T x) {if (x<0) return putchar('-'), print(-x);if (x<10) {putchar(x+'0');return ;} print(x/10);putchar(x%10+'0');}

template<class U, class V>inline void gn(U &u, V &v){gn(u);gn(v);}

template<class U, class V, class W>inline void gn(U &u, V &v, W &w){gn(u); gn(v, w);}

template<class T> void println(T &x) {print(x);putchar('\n');}

template<class T> void printsp(T &x) {print(x);putchar(' ');}

template<class U, class V> inline void print(U &u, V &v) {printsp(u);println(v);}

template<class U, class V, class W> inline void print(U &u, V &v, W &w){printsp(u);print(v, w);}

int power(int a, int b, int m=MOD, int ans=1) {

	for (; b; a=(INT)a*a%MOD,b>>=1) if (b&1) ans=(INT)ans*a%MOD;

	return ans;

}

#define NN 110101

INT sum[NN];

int deep[NN],cnt[NN],mx=0;

VI adj[NN];

void judge(int u,int fa=0){

	deep[u]=deep[fa]+1;

	cnt[deep[u]]++;

	smax(mx,deep[u]);

	for(int i=0;i<adj[u].size();i++){

		int v=adj[u][i];

		if(v==fa) continue;

		judge(v,u);

	}

}

int main() {

#ifndef ONLINE_JUDGE

	freopen("in.in", "r", stdin);

	freopen("out.out", "w", stdout);

#endif

	int n,k,p;

	gn(n,k,p);

	for(int i=0;i<n-1;i++){

		int u,v;

		gn(u,v);

		adj[u].push_back(v);

		adj[v].push_back(u);

	}

	judge(1);

	INT tmp=0;

	int ans=0;

	for(int i=2;i<=mx;i++){

		sum[i]=sum[i-1]+cnt[i];

		int cur=2;

		tmp+=sum[i-1]-sum[cur-1];

		while(p<tmp){

			tmp-=(INT) cnt[cur]*(i-cur);

			cur++;

		}

		int res=sum[i]-sum[cur-1];

		if(cur>2) res+=min((INT) cnt[cur-1],(p-tmp)/(i-cur+1));

		smax(ans,res);

	}

	printf("%d\n",min(k,ans));

	return 0;

}


/* --- Author: Vladimir Smykalov, enot.1.10@gmail.com --- */
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <string>
#include <cstring>
#include <cmath>
#include <algorithm>
#include <vector>
#include <set>
#include <map>
#include <ctime>
#include <cassert>

#define fs first
#define sc second
#define pb push_back
#define mp make_pair
#define forn(i, n) for(int i = 0 ; (i) < (n) ; ++i)
#define forit(it,v) for(typeof((v).begin()) it = v.begin() ; it != (v).end() ; ++it)
#define eprintf(...) fprintf(stderr, __VA_ARGS__),fflush(stderr)
#define sz(a) ((int)(a).size())
#define all(a) (a).begin(),a.end()

using namespace std;

typedef long long ll;
typedef double ld;
typedef vector<int> vi;
typedef pair<int, int> pi;

const int inf = (int)1e9;
const ld eps = 1e-9;

/* --- main part --- */

#define TASK "a"

const int maxn = (int)1e5 + 10;
const int maxe = 2 * maxn;

int head[maxn], next[maxe], to[maxe], ec = 1;
inline void add(int x, int y)
{
    ec += 1;
    to[ec] = y;
    next[ec] = head[x];
    head[x] = ec;
}

int a[maxn];
int mark[maxn];
int N = 0;

void dfs(int x, int dep)
{
    mark[x] = 1;
    a[dep] += 1;
    N = max(N, dep + 1);
    for (int e = head[x]; e; e = next[e]) if (mark[to[e]] == 0) dfs(to[e], dep + 1);
}

ll sum[maxn];
ll sum2[maxn];

int res = 0;
int n, k, p;

void Do(int R)
{
    if (a[R] >= k)
    {
        res = k;
        return;
    }
    int l = 1, r = R;
    while (l < r)
    {
        int m = (l + r) >> 1;
        ll K = sum[R + 1] - sum[m];
        ll P = (sum2[R + 1] - sum[m]) + K * (R + 1);
        if (P <= p) r = m;
        else l = m + 1;
    }
    ll K = sum[R + 1] - sum[r];
    ll P = (sum2[R + 1] - sum[r]) + K * R;
    int leftP = p - P;
    int can_add = 0;
    if (r > 1) can_add = leftP / (R - r + 1);
    res = max(res, (int)(K + can_add));
}

int main()
{
    #ifdef home
        assert(freopen(TASK".in", "r", stdin));
        assert(freopen(TASK".out", "w", stdout));
    #endif
    scanf("%d%d%d", &n, &k, &p);
    forn(i, n - 1)
    {
        int x, y;
        scanf("%d%d", &x, &y);
        x -= 1, y -= 1;
        add(x, y);
        add(y, x);
    }
    dfs(0, 0);
    forn(i, N) sum[i + 1] = sum[i] + a[i];
    forn(i, N) sum2[i + 1] = sum2[i] - a[i] * i;

    for (int i = 1; i < N; ++i) Do(i);

    res = min(res, k);
    printf("%d\n", res);
    #ifdef home
        eprintf("Time: %d ms\n", (int)(clock() * 1000. / CLOCKS_PER_SEC));
    #endif
    return 0;
}


/* --- Author: Vladimir Smykalov, enot.1.10@gmail.com --- */
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <string>
#include <cstring>
#include <cmath>
#include <algorithm>
#include <vector>
#include <set>
#include <map>
#include <ctime>
#include <cassert>

#define fs first
#define sc second
#define pb push_back
#define mp make_pair
#define forn(i, n) for(int i = 0 ; (i) < (n) ; ++i)
#define forit(it,v) for(typeof((v).begin()) it = v.begin() ; it != (v).end() ; ++it)
#define eprintf(...) fprintf(stderr, __VA_ARGS__),fflush(stderr)
#define sz(a) ((int)(a).size())
#define all(a) (a).begin(),a.end()

using namespace std;

typedef long long ll;
typedef double ld;
typedef vector<int> vi;
typedef pair<int, int> pi;

const int inf = (int)1e9;
const ld eps = 1e-9;

/* --- main part --- */

#define TASK "a"

const int maxn = (int)1e5 + 10;
const int maxe = 2 * maxn;

int head[maxn], next[maxe], to[maxe], ec = 1;
inline void add(int x, int y)
{
    ec += 1;
    to[ec] = y;
    next[ec] = head[x];
    head[x] = ec;
}

int a[maxn];
int mark[maxn];
int N = 0;

void dfs(int x, int dep)
{
    mark[x] = 1;
    a[dep] += 1;
    N = max(N, dep + 1);
    for (int e = head[x]; e; e = next[e]) if (mark[to[e]] == 0) dfs(to[e], dep + 1);
}

ll sum[maxn];
ll sum2[maxn];

int res = 0;
int n, k, p;

void Do(int R)
{
    if (a[R] >= k)
    {
        res = k;
        return;
    }
    int l = 1, r = R;
    while (l < r)
    {
        int m = (l + r) >> 1;
        ll K = sum[R + 1] - sum[m];
        ll P = (sum2[R + 1] - sum[m]) + K * (R + 1);
        if (K <= k && P <= p) r = m;
        else l = m + 1;
    }
    ll K = sum[R + 1] - sum[r];
    ll P = (sum2[R + 1] - sum[r]) + K * R;
    int leftP = p - P;
    int can_add = 0;
    if (r > 1) can_add = leftP / (R - r + 1);
    res = max(res, (int)(K + can_add));
}

int main()
{
    #ifdef home
        assert(freopen(TASK".in", "r", stdin));
        assert(freopen(TASK".out", "w", stdout));
    #endif
    scanf("%d%d%d", &n, &k, &p);
    forn(i, n - 1)
    {
        int x, y;
        scanf("%d%d", &x, &y);
        x -= 1, y -= 1;
        add(x, y);
        add(y, x);
    }
    dfs(0, 0);
    forn(i, N) sum[i + 1] = sum[i] + a[i];
    forn(i, N) sum2[i + 1] = sum2[i] - a[i] * i;

    for (int i = 1; i < N; ++i) Do(i);

    printf("%d\n", res);
    #ifdef home
        eprintf("Time: %d ms\n", (int)(clock() * 1000. / CLOCKS_PER_SEC));
    #endif
    return 0;
}


/* --- Author: Vladimir Smykalov, enot.1.10@gmail.com --- */
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <string>
#include <cstring>
#include <cmath>
#include <algorithm>
#include <vector>
#include <set>
#include <map>
#include <ctime>
#include <cassert>

#define fs first
#define sc second
#define pb push_back
#define mp make_pair
#define forn(i, n) for(int i = 0 ; (i) < (n) ; ++i)
#define forit(it,v) for(typeof((v).begin()) it = v.begin() ; it != (v).end() ; ++it)
#define eprintf(...) fprintf(stderr, __VA_ARGS__),fflush(stderr)
#define sz(a) ((int)(a).size())
#define all(a) (a).begin(),a.end()

using namespace std;

typedef long long ll;
typedef double ld;
typedef vector<int> vi;
typedef pair<int, int> pi;

const int inf = (int)1e9;
const ld eps = 1e-9;

/* --- main part --- */

#define TASK "a"

const int maxn = (int)1e5 + 10;
const int maxe = 2 * maxn;

int head[maxn], next[maxe], to[maxe], ec = 1;
inline void add(int x, int y)
{
    ec += 1;
    to[ec] = y;
    next[ec] = head[x];
    head[x] = ec;
}

int a[maxn];
int mark[maxn];
int N = 0;

void dfs(int x, int dep)
{
    mark[x] = 1;
    a[dep] += 1;
    N = max(N, dep + 1);
    for (int e = head[x]; e; e = next[e]) if (mark[to[e]] == 0) dfs(to[e], dep + 1);
}

ll sum[maxn];
ll sum2[maxn];

int res = 0;
int n, k, p;

void Do(int R)
{
    if (a[R] >= k)
    {
        res = k;
        return;
    }
    int l = 1, r = R;
    while (l < r)
    {
        int m = (l + r) >> 1;
        ll K = sum[R + 1] - sum[m];
        ll P = (sum2[R + 1] - sum2[m]) + K * R;
        if (P <= p) r = m;
        else l = m + 1;
    }
    ll K = sum[R + 1] - sum[r];
    ll P = (sum2[R + 1] - sum2[r]) + K * R;
    int leftP = p - P;
    int can_add = 0;
    if (r > 1) can_add = leftP / (R - r + 1);
    res = max(res, (int)(K + can_add));
}

int main()
{
    #ifdef home
        assert(freopen(TASK".in", "r", stdin));
        assert(freopen(TASK".out", "w", stdout));
    #endif
    scanf("%d%d%d", &n, &k, &p);
    forn(i, n - 1)
    {
        int x, y;
        scanf("%d%d", &x, &y);
        x -= 1, y -= 1;
        add(x, y);
        add(y, x);
    }
    dfs(0, 0);
    forn(i, N) sum[i + 1] = sum[i] + a[i];
    forn(i, N) sum2[i + 1] = sum2[i] - a[i] * i;

    for (int i = 1; i < N; ++i) Do(i);

    res = min(res, k);
    printf("%d\n", res);
    #ifdef home
        eprintf("Time: %d ms\n", (int)(clock() * 1000. / CLOCKS_PER_SEC));
    #endif
    return 0;
}


/* --- Author: Vladimir Smykalov, enot.1.10@gmail.com --- */
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <string>
#include <cstring>
#include <cmath>
#include <algorithm>
#include <vector>
#include <set>
#include <map>
#include <ctime>
#include <cassert>

#define fs first
#define sc second
#define pb push_back
#define mp make_pair
#define forn(i, n) for(int i = 0 ; (i) < (n) ; ++i)
#define forit(it,v) for(typeof((v).begin()) it = v.begin() ; it != (v).end() ; ++it)
#define eprintf(...) fprintf(stderr, __VA_ARGS__),fflush(stderr)
#define sz(a) ((int)(a).size())
#define all(a) (a).begin(),a.end()

using namespace std;

typedef long long ll;
typedef double ld;
typedef vector<int> vi;
typedef pair<int, int> pi;

const int inf = (int)1e9;
const ld eps = 1e-9;

/* --- main part --- */

#define TASK "a"

const int maxn = (int)1e5 + 10;
const int maxe = 2 * maxn;

int head[maxn], next[maxe], to[maxe], ec = 1;
inline void add(int x, int y)
{
    ec += 1;
    to[ec] = y;
    next[ec] = head[x];
    head[x] = ec;
}

int a[maxn];
int mark[maxn];
int N = 0;

void dfs(int x, int dep)
{
    mark[x] = 1;
    a[dep] += 1;
    N = max(N, dep + 1);
    for (int e = head[x]; e; e = next[e]) if (mark[to[e]] == 0) dfs(to[e], dep + 1);
}

ll sum[maxn];
ll sum2[maxn];

int res = 0;
int n, k, p;

void Do(int R)
{
    if (a[R] >= k)
    {
        res = k;
        return;
    }
    int l = 1, r = R;
    while (l < r)
    {
        int m = (l + r) >> 1;
        ll K = sum[R + 1] - sum[m];
        ll P = (sum2[R + 1] - sum[m]) + K * R;
        if (P <= p) r = m;
        else l = m + 1;
    }
    ll K = sum[R + 1] - sum[r];
    ll P = (sum2[R + 1] - sum[r]) + K * R;
    int leftP = p - P;
    int can_add = 0;
    if (r > 1) can_add = leftP / (R - r + 1);
    res = max(res, (int)(K + can_add));
}

int main()
{
    #ifdef home
        assert(freopen(TASK".in", "r", stdin));
        assert(freopen(TASK".out", "w", stdout));
    #endif
    scanf("%d%d%d", &n, &k, &p);
    forn(i, n - 1)
    {
        int x, y;
        scanf("%d%d", &x, &y);
        x -= 1, y -= 1;
        add(x, y);
        add(y, x);
    }
    dfs(0, 0);
    forn(i, N) sum[i + 1] = sum[i] + a[i];
    forn(i, N) sum2[i + 1] = sum2[i] - a[i] * i;

    for (int i = 1; i < N; ++i) Do(i);

    res = min(res, k);
    printf("%d\n", res);
    #ifdef home
        eprintf("Time: %d ms\n", (int)(clock() * 1000. / CLOCKS_PER_SEC));
    #endif
    return 0;
}


/*
ID: keyvank2
TASK: combo
LANG: C++
*/

#include <bits/stdc++.h>

#define ff first
#define ss second
#define pb push_back
#define mp make_pair
#define MAXINT ((~0) ^ (1 << 31))
#define MAXLL ((~0) ^ ((ll)1 << 63))
#define INF ((int)2e9)
#define INFL ((ll)9e18)
#define FOR(i,j,k) for(int i = j; i < k; i++)
#define REP(i,j,k) for(int i = j; i >= k; i--)
#define setmax(i) const int maxn = (int) i;
#define setmod(i) const int MOD = (int) i;
#define all(a) a.begin(),a.end()

using namespace std;

//ifstream fin("");
//ofstream fout("");
//#define cin fin
//#define cout fout

typedef long long ll;
typedef long double ld;
typedef vector<ll> vi;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef pair<ld,ld> pdd;
typedef pair<pii,int> ppi;
typedef pair<pll,ll> ppl;
typedef pair<int,pii> pip;
typedef pair<ll,pll> plp;
typedef pair<pii,pii> ppp;

template<class T> inline T pow2(T a) {return a*a;}
template<class T> inline bool mineq(T& a, T b) { if(a < b) {a=b;return true;} return false;}

//srand (time(NULL));

setmax(1e5+10);
int n,k,c, dep[maxn], dist[maxn], sdep[maxn];
bool visited[maxn];
vi num[maxn];

void bfs()
{
    queue<int> q;
    int src = 1;
    q.push(1);
    dist[1] = 0;
    visited[1] = true;
    while(!q.empty())
    {
	src = q.front();
	dep[dist[src]]++;
	q.pop();
	FOR(i,0,num[src].size())
	{
	    int u = num[src][i];
	    if(visited[u]) continue;
	    dist[u] = dist[src] + 1;
	    visited[u] = true;
	    q.push(u);
	}
    }
}

bool ok(int t)
{
    FOR(i,1,n)
    {
	int j = upper_bound(dep,dep+n,dep[i]-t) - dep;

//	if(t == 1 && i == 1) cout <<"* " <<dep[i] << " " << j << " " << dep[j] << endl;

	//if(j == -1 || dep[i] - dep[j] < t) continue;

	int rem = t - (dep[i] - dep[j]);
	if(j == 0 && rem != 0) continue;

	if(j != n && sdep[i] - sdep[j] + rem*dep[j]*(j-i) <= c) return true;
    }
    return false;
}

int main()
{
    ios_base::sync_with_stdio(0);cin.tie(0);

    cin >> n >> k >> c;
    FOR(i,0,n-1)
    {
	int a,b;
	cin >> a >> b;
	num[a].pb(b);
	num[b].pb(a);
    }

    bfs();
    dep[0] = 0;
    FOR(i,1,n) dep[i] += dep[i-1];
    FOR(i,1,n) sdep[i] = sdep[i-1]+dep[i];

    //FOR(i,0,n) cout << dep[i] << " ";
    int l = 0, r = k, ans = 0;
    while(l <= r)
    {
	int mid = (l+r)/2;
//	cout << mid << endl;
	if(ok(mid))
	{
	    ans = mid;
	    l = mid+1;
	}
	else
	{
	    r = mid-1;
	}
    }
    cout << ans;
}


/*
ID: keyvank2
TASK: combo
LANG: C++
*/

#include <bits/stdc++.h>

#define ff first
#define ss second
#define pb push_back
#define mp make_pair
#define MAXINT ((~0) ^ (1 << 31))
#define MAXLL ((~0) ^ ((ll)1 << 63))
#define INF ((int)2e9)
#define INFL ((ll)9e18)
#define FOR(i,j,k) for(int i = j; i < k; i++)
#define REP(i,j,k) for(int i = j; i >= k; i--)
#define setmax(i) const int maxn = (int) i;
#define setmod(i) const int MOD = (int) i;
#define all(a) a.begin(),a.end()

using namespace std;

//ifstream fin("");
//ofstream fout("");
//#define cin fin
//#define cout fout

typedef long long ll;
typedef long double ld;
typedef vector<ll> vi;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef pair<ld,ld> pdd;
typedef pair<pii,int> ppi;
typedef pair<pll,ll> ppl;
typedef pair<int,pii> pip;
typedef pair<ll,pll> plp;
typedef pair<pii,pii> ppp;

template<class T> inline T pow2(T a) {return a*a;}
template<class T> inline bool mineq(T& a, T b) { if(a < b) {a=b;return true;} return false;}

//srand (time(NULL));

setmax(1e5+10);
int n,k,c, dep[maxn], dist[maxn], sdep[maxn];
bool visited[maxn];
vi num[maxn];

void bfs()
{
    queue<int> q;
    int src = 1;
    q.push(1);
    dist[1] = 0;
    visited[1] = true;
    while(!q.empty())
    {
	src = q.front();
	dep[dist[src]]++;
	q.pop();
	FOR(i,0,num[src].size())
	{
	    int u = num[src][i];
	    if(visited[u]) continue;
	    dist[u] = dist[src] + 1;
	    visited[u] = true;
	    q.push(u);
	}
    }
}

bool ok(int t)
{
    FOR(i,1,n)
    {
	int j = lower_bound(dep,dep+n,t+dep[i-1]) - dep;
	if(j != n && sdep[j] - sdep[i] <= c) return true;
    }
    return false;
}

int main()
{
    ios_base::sync_with_stdio(0);cin.tie(0);

    cin >> n >> k >> c;
    FOR(i,0,n-1)
    {
	int a,b;
	cin >> a >> b;
	num[a].pb(b);
	num[b].pb(a);
    }

    bfs();
    dep[0] = 0;
    FOR(i,1,n) dep[i] += dep[i-1];
    FOR(i,1,n) sdep[i] = sdep[i-1]+dep[i];

    //FOR(i,0,n) cout << dep[i] << " ";
    int l = 0, r = k, ans = 0;
    while(l <= r)
    {
	int mid = (l+r)/2;
	if(ok(mid))
	{
	    ans = mid;
	    l = mid+1;
	}
	else
	{
	    r = mid-1;
	}
    }
    cout << min(ans,k);
}


/*
ID: keyvank2
TASK: combo
LANG: C++
*/

#include <bits/stdc++.h>

#define ff first
#define ss second
#define pb push_back
#define mp make_pair
#define MAXINT ((~0) ^ (1 << 31))
#define MAXLL ((~0) ^ ((ll)1 << 63))
#define INF ((int)2e9)
#define INFL ((ll)9e18)
#define FOR(i,j,k) for(int i = j; i < k; i++)
#define REP(i,j,k) for(int i = j; i >= k; i--)
#define setmax(i) const int maxn = (int) i;
#define setmod(i) const int MOD = (int) i;
#define all(a) a.begin(),a.end()

using namespace std;

//ifstream fin("");
//ofstream fout("");
//#define cin fin
//#define cout fout

typedef long long ll;
typedef long double ld;
typedef vector<ll> vi;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef pair<ld,ld> pdd;
typedef pair<pii,int> ppi;
typedef pair<pll,ll> ppl;
typedef pair<int,pii> pip;
typedef pair<ll,pll> plp;
typedef pair<pii,pii> ppp;

template<class T> inline T pow2(T a) {return a*a;}
template<class T> inline bool mineq(T& a, T b) { if(a < b) {a=b;return true;} return false;}

//srand (time(NULL));

setmax(1e5+10);
int n,k,c, dep[maxn], dist[maxn];
bool visited[maxn];
vi num[maxn];

void bfs()
{
    queue<int> q;
    int src = 1;
    q.push(1);
    dist[1] = 0;
    visited[1] = true;
    while(!q.empty())
    {
	src = q.front();
	dep[dist[src]]++;
	q.pop();
	FOR(i,0,num[src].size())
	{
	    int u = num[src][i];
	    if(visited[u]) continue;
	    dist[u] = dist[src] + 1;
	    visited[u] = true;
	    q.push(u);
	}
    }
}

bool ok(int t)
{
    dep[0] = 0;
    int p = 0, p2 = 0, coin = 0, sum = 0;
    while(p2 < n)
    {
	if(sum >= t)
	{
	    coin -= dep[p] * (p2 - p);
	    sum -= dep[p];
	    p++;
	}
	else
	{
	    p2++;
	    coin += sum;
	    sum += dep[p2];
	}
	if(sum >= t && coin <= c) return true;
    }
    return false;
}

int main()
{
    ios_base::sync_with_stdio(0);cin.tie(0);

    cin >> n >> k >> c;
    FOR(i,0,n-1)
    {
	int a,b;
	cin >> a >> b;
	num[a].pb(b);
	num[b].pb(a);
    }
    bfs();

    //FOR(i,0,n) cout << dep[i] << " ";
    int l = 0, r = k, ans = 0;
    while(l <= r)
    {
	int mid = (l+r)/2;
	if(ok(mid))
	{
	    ans = mid;
	    l = mid+1;
	}
	else
	{
	    r = mid-1;
	}
    }
    cout << min(ans,k);
}


/*
ID: keyvank2
TASK: combo
LANG: C++
*/

#include <bits/stdc++.h>

#define ff first
#define ss second
#define pb push_back
#define mp make_pair
#define MAXINT ((~0) ^ (1 << 31))
#define MAXLL ((~0) ^ ((ll)1 << 63))
#define INF ((int)2e9)
#define INFL ((ll)9e18)
#define FOR(i,j,k) for(int i = j; i < k; i++)
#define REP(i,j,k) for(int i = j; i >= k; i--)
#define setmax(i) const int maxn = (int) i;
#define setmod(i) const int MOD = (int) i;
#define all(a) a.begin(),a.end()

using namespace std;

//ifstream fin("");
//ofstream fout("");
//#define cin fin
//#define cout fout

typedef long long ll;
typedef long double ld;
typedef vector<ll> vi;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef pair<ld,ld> pdd;
typedef pair<pii,int> ppi;
typedef pair<pll,ll> ppl;
typedef pair<int,pii> pip;
typedef pair<ll,pll> plp;
typedef pair<pii,pii> ppp;

template<class T> inline T pow2(T a) {return a*a;}
template<class T> inline bool mineq(T& a, T b) { if(a < b) {a=b;return true;} return false;}

//srand (time(NULL));

setmax(1e5+10);
int n,k,c, dep[maxn], dist[maxn], sdep[maxn];
bool visited[maxn];
vi num[maxn];

void bfs()
{
    queue<int> q;
    int src = 1;
    q.push(1);
    dist[1] = 0;
    visited[1] = true;
    while(!q.empty())
    {
	src = q.front();
	dep[dist[src]]++;
	q.pop();
	FOR(i,0,num[src].size())
	{
	    int u = num[src][i];
	    if(visited[u]) continue;
	    dist[u] = dist[src] + 1;
	    visited[u] = true;
	    q.push(u);
	}
    }
}

bool ok(int t)
{
    FOR(i,1,n)
    {
	int j = upper_bound(dep,dep+n,dep[i]-t) - dep;
	//if(t == 1 && i == 1) cout <<"* " <<dep[i] << " " << j << " " << dep[j] << endl;
	//cout << t << " " << i << " " << dep[i] << " " << j <<endl;
	//if(j == -1 || dep[i] - dep[j] < t) continue;
	if(j == 0)continue;
	int rem = t - (dep[i] - dep[j-1]);
	if(j-1 == 0 && dep[i] < t) continue;

	if(j != n && sdep[i] - sdep[j] + rem*(i-j) <= c) return true;
    }
    return false;
}

int main()
{
    ios_base::sync_with_stdio(0);cin.tie(0);

    cin >> n >> k >> c;
    FOR(i,0,n-1)
    {
	int a,b;
	cin >> a >> b;
	num[a].pb(b);
	num[b].pb(a);
    }

    bfs();
    dep[0] = 0;
    FOR(i,1,n) dep[i] += dep[i-1];
    FOR(i,1,n) sdep[i] = sdep[i-1]+dep[i];

    //FOR(i,0,n) cout << dep[i] << " ";
    int l = 0, r = k, ans = 0;
    while(l <= r)
    {
	int mid = (l+r)/2;
//	cout << mid << endl;
	if(ok(mid))
	{
	    ans = mid;
	    l = mid+1;
	}
	else
	{
	    r = mid-1;
	}
    }
    cout << ans;
}


/*
ID: keyvank2
TASK: combo
LANG: C++
*/

#include <bits/stdc++.h>

#define ff first
#define ss second
#define pb push_back
#define mp make_pair
#define MAXINT ((~0) ^ (1 << 31))
#define MAXLL ((~0) ^ ((ll)1 << 63))
#define INF ((int)2e9)
#define INFL ((ll)9e18)
#define FOR(i,j,k) for(int i = j; i < k; i++)
#define REP(i,j,k) for(int i = j; i >= k; i--)
#define setmax(i) const int maxn = (int) i;
#define setmod(i) const int MOD = (int) i;
#define all(a) a.begin(),a.end()

using namespace std;

//ifstream fin("");
//ofstream fout("");
//#define cin fin
//#define cout fout

typedef long long ll;
typedef long double ld;
typedef vector<ll> vi;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef pair<ld,ld> pdd;
typedef pair<pii,int> ppi;
typedef pair<pll,ll> ppl;
typedef pair<int,pii> pip;
typedef pair<ll,pll> plp;
typedef pair<pii,pii> ppp;

template<class T> inline T pow2(T a) {return a*a;}
template<class T> inline bool mineq(T& a, T b) { if(a < b) {a=b;return true;} return false;}

//srand (time(NULL));

setmax(1e5+10);
int n,k,c, dep[maxn], dist[maxn], sdep[maxn];
bool visited[maxn];
vi num[maxn];

void bfs()
{
    queue<int> q;
    int src = 1;
    q.push(1);
    dist[1] = 0;
    visited[1] = true;
    while(!q.empty())
    {
	src = q.front();
	dep[dist[src]]++;
	q.pop();
	FOR(i,0,num[src].size())
	{
	    int u = num[src][i];
	    if(visited[u]) continue;
	    dist[u] = dist[src] + 1;
	    visited[u] = true;
	    q.push(u);
	}
    }
}

bool ok(int t)
{
    FOR(i,1,n)
    {
	if(dep[i] < t) continue;
	int j = upper_bound(dep,dep+n,dep[i]-t) - dep;
	//if(t == 1 && i == 1) cout <<"* " <<dep[i] << " " << j << " " << dep[j] << endl;
	//cout << t << " " << i << " " << dep[i] << " " << j <<endl;
	//if(j == -1 || dep[i] - dep[j] < t) continue;

	int rem = t - (dep[i] - dep[j-1]);

	if(j != n && sdep[i] - sdep[j] + rem*(i-j) <= c) return true;
    }
    return false;
}

int main()
{
    ios_base::sync_with_stdio(0);cin.tie(0);

    cin >> n >> k >> c;
    FOR(i,0,n-1)
    {
	int a,b;
	cin >> a >> b;
	num[a].pb(b);
	num[b].pb(a);
    }

    bfs();
    dep[0] = 0;
    FOR(i,1,n) dep[i] += dep[i-1];
    FOR(i,1,n) sdep[i] = sdep[i-1]+dep[i];

    //FOR(i,0,n) cout << dep[i] << " ";
    int l = 0, r = k, ans = 0;
    while(l <= r)
    {
	int mid = (l+r)/2;
//	cout << mid << endl;
	if(ok(mid))
	{
	    ans = mid;
	    l = mid+1;
	}
	else
	{
	    r = mid-1;
	}
    }
    cout << ans;
}


/*
ID: keyvank2
TASK: combo
LANG: C++
*/

#include <bits/stdc++.h>

#define ff first
#define ss second
#define pb push_back
#define mp make_pair
#define MAXINT ((~0) ^ (1 << 31))
#define MAXLL ((~0) ^ ((ll)1 << 63))
#define INF ((int)2e9)
#define INFL ((ll)9e18)
#define FOR(i,j,k) for(int i = j; i < k; i++)
#define REP(i,j,k) for(int i = j; i >= k; i--)
#define setmax(i) const int maxn = (int) i;
#define setmod(i) const int MOD = (int) i;
#define all(a) a.begin(),a.end()

using namespace std;

//ifstream fin("");
//ofstream fout("");
//#define cin fin
//#define cout fout

typedef long long ll;
typedef long double ld;
typedef vector<ll> vi;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef pair<ld,ld> pdd;
typedef pair<pii,int> ppi;
typedef pair<pll,ll> ppl;
typedef pair<int,pii> pip;
typedef pair<ll,pll> plp;
typedef pair<pii,pii> ppp;

template<class T> inline T pow2(T a) {return a*a;}
template<class T> inline bool mineq(T& a, T b) { if(a < b) {a=b;return true;} return false;}

//srand (time(NULL));

setmax(1e5+10);
int n,k,c, dep[maxn], dist[maxn];
bool visited[maxn];
vi num[maxn];

void bfs()
{
    queue<int> q;
    int src = 1;
    q.push(1);
    dist[1] = 0;
    visited[1] = true;
    while(!q.empty())
    {
	src = q.front();
	dep[dist[src]]++;
	q.pop();
	FOR(i,0,num[src].size())
	{
	    int u = num[src][i];
	    if(visited[u]) continue;
	    dist[u] = dist[src] + 1;
	    visited[u] = true;
	    q.push(u);
	}
    }
}

bool ok(int t)
{
    dep[0] = 0;
    int p = 0, p2 = 0, coin = 0, sum = 0;
    while(p2 < n)
    {
	if(sum >= t || coin > c)
	{
	    coin -= dep[p] * (p2 - p);
	    sum -= dep[p];
	    p++;
	}
	else
	{
	    p2++;
	    coin += sum;
	    sum += dep[p2];
	}
	if(sum >= t && coin <= c) return true;
    }
    return false;
}

int main()
{
    ios_base::sync_with_stdio(0);cin.tie(0);

    cin >> n >> k >> c;
    FOR(i,0,n-1)
    {
	int a,b;
	cin >> a >> b;
	num[a].pb(b);
	num[b].pb(a);
    }
    bfs();

    //FOR(i,0,n) cout << dep[i] << " ";
    int l = 0, r = k, ans = 0;
    while(l <= r)
    {
	int mid = (l+r)/2;
	if(ok(mid))
	{
	    ans = mid;
	    l = mid+1;
	}
	else
	{
	    r = mid-1;
	}
    }
    cout << min(ans,k);
}


/*
ID: keyvank2
TASK: combo
LANG: C++
*/

#include <bits/stdc++.h>

#define ff first
#define ss second
#define pb push_back
#define mp make_pair
#define MAXINT ((~0) ^ (1 << 31))
#define MAXLL ((~0) ^ ((ll)1 << 63))
#define INF ((int)2e9)
#define INFL ((ll)9e18)
#define FOR(i,j,k) for(int i = j; i < k; i++)
#define REP(i,j,k) for(int i = j; i >= k; i--)
#define setmax(i) const int maxn = (int) i;
#define setmod(i) const int MOD = (int) i;
#define all(a) a.begin(),a.end()

using namespace std;

//ifstream fin("");
//ofstream fout("");
//#define cin fin
//#define cout fout

typedef long long ll;
typedef long double ld;
typedef vector<ll> vi;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef pair<ld,ld> pdd;
typedef pair<pii,int> ppi;
typedef pair<pll,ll> ppl;
typedef pair<int,pii> pip;
typedef pair<ll,pll> plp;
typedef pair<pii,pii> ppp;

template<class T> inline T pow2(T a) {return a*a;}
template<class T> inline bool mineq(T& a, T b) { if(a < b) {a=b;return true;} return false;}

//srand (time(NULL));

setmax(1e5+10);
int n,k,c, dep[maxn], dist[maxn], sdep[maxn];
bool visited[maxn];
vi num[maxn];

void bfs()
{
    queue<int> q;
    int src = 1;
    q.push(1);
    dist[1] = 0;
    visited[1] = true;
    while(!q.empty())
    {
	src = q.front();
	dep[dist[src]]++;
	q.pop();
	FOR(i,0,num[src].size())
	{
	    int u = num[src][i];
	    if(visited[u]) continue;
	    dist[u] = dist[src] + 1;
	    visited[u] = true;
	    q.push(u);
	}
    }
}

int main()
{
    ios_base::sync_with_stdio(0);cin.tie(0);

    cin >> n >> k >> c;
    FOR(i,0,n-1)
    {
	int a,b;
	cin >> a >> b;
	num[a].pb(b);
	num[b].pb(a);
    }

    bfs();
    dep[0] = 0;
    //FOR(i,1,n) dep[i] += dep[i-1];
    //FOR(i,1,n) sdep[i] = sdep[i-1]+dep[i];

    int p = 0, cost = 0, sum = 0, ans = 0;
    FOR(i,1,n)
    {
	cost += sum;
	sum += dep[i];
	while(cost > c)
	{
	    //cout << cost << " " << p << " " << sum << endl;
	    cost -= dep[p]*(i-p);
	    sum -= dep[p];
	    p++;
	    //if(sum < 0) exit(0);
	}
	ans = max(ans, sum + (p > 1 ? (c - cost)/(i-p+1) : 0));
    }
    cout << min(ans,k);
}


#include<iostream>
#include<algorithm>
#include<vector>
using namespace std;
typedef long long Int;
#define MOD 1000000007
vector<int> edge[108000];
Int ver[108000];
Int dep[108000];
bool compare(const Int &a, const Int &b){
	return dep[a] > dep[b];
}

void dfs(Int x, Int last = -1, Int d = 0){
	dep[x] = d;
	for(Int i = 0;i < edge[x].size();i++){
		if(last == edge[x][i])continue;
		dfs(edge[x][i], x, d + 1);
	}
}

int main(){
	Int m, k, p, a, b;
	cin >> m >> k >> p;
	if(k == 0){
		cout << 0 << endl;
		return 0;
	}
	for(Int i = 1;i < m;i++){
		cin >> a >> b;
		edge[a].push_back(b);
		edge[b].push_back(a);
		ver[i - 1] = i;
	}
	ver[m - 1] = m;
	dfs(1);
	sort(ver, ver + m, compare);
	m--;
	Int r = 0, sum = 0, res = 0;
	for(Int l = 0;l < m;l++){
		while(r < m && (r - l + 1) <= k && sum - (r - l + 1) * dep[l] <= p){
			sum += dep[++r];
		}
		sum -= dep[r--];
		if(r < l){
			while(r < l)sum += [++r];
			sum -= dep[l];
			continue;
		}
		res = max(res, (r - l + 1));
		sum -= dep[l];
	}
	cout << res << endl;
	return 0;

}


#include<iostream>
#include<algorithm>
#include<vector>
using namespace std;
typedef long long Int;
#define MOD 1000000007
vector<int> edge[108000];
Int ver[108000];
Int dep[108000];
bool compare(const Int &a, const Int &b){
	return dep[a] > dep[b];
}

void dfs(Int x, Int last = -1, Int d = 0){
	dep[x] = d;
	for(Int i = 0;i < edge[x].size();i++){
		if(last == edge[x][i])continue;
		dfs(edge[x][i], x, d + 1);
	}
}

int main(){
	Int m, k, p, a, b;
	cin >> m >> k >> p;
	if(k == 0){
		cout << 0 << endl;
		return 0;
	}
	for(Int i = 1;i < m;i++){
		cin >> a >> b;
		edge[a].push_back(b);
		edge[b].push_back(a);
		ver[i - 1] = i;
	}
	ver[m - 1] = m;
	dfs(1);
	sort(ver, ver + m, compare);
	m--;
	Int r = 0, sum = 0, res = 0;
	for(Int l = 0;l < m;l++){
		while(r < m && (r - l + 1) <= k && sum - (r - l + 1) * dep[l] <= p){
			sum += dep[++r];
		}
		sum -= dep[r--];
		if(r < l){
			while(r < l)sum += dep[++r];
			sum -= dep[l];
			continue;
		}
		res = max(res, (r - l + 1));
		sum -= dep[l];
	}
	cout << res << endl;
	return 0;

}


#include<iostream>
#include<algorithm>
#include<vector>
using namespace std;
typedef long long Int;
#define MOD 1000000007
vector<int> edge[108000];
Int ver[108000];
Int dep[108000];
Int imos[108000];
bool compare(const Int &a, const Int &b){
	return dep[a] > dep[b];
}

void dfs(Int x, Int last = -1, Int d = 0){
	dep[x] = d;
	for(Int i = 0;i < edge[x].size();i++){
		if(last == edge[x][i])continue;
		dfs(edge[x][i], x, d + 1);
	}
}

int main(){
	Int m, k, p, a, b;
	cin >> m >> k >> p;
	if(k == 0){
		cout << 0 << endl;
		return 0;
	}
	for(Int i = 1;i < m;i++){
		cin >> a >> b;
		edge[a].push_back(b);
		edge[b].push_back(a);
		ver[i - 1] = i;
	}
	ver[m - 1] = m;
	dfs(1);
	sort(ver, ver + m, compare);
	for(int i = 1;i <= m;i++){
		imos[i] = imos[i - 1] + dep[ver[i - 1]];
	}
	m--;
	Int r = 0, res = 0;
	for(Int l = 0;l < m;l++){
		r = max(l, r);
		while(r < m && (r - l + 1) <= k && imos[r + 1] - imos[l] - (r - l + 1) * dep[ver[l]] <= p){
			r++;
		}
		r--;
		res = max(res, r - l + 1);
	}
	cout << res << endl;
	return 0;

}


#include<iostream>
#include<algorithm>
#include<vector>
using namespace std;
typedef long long Int;
#define MOD 1000000007
vector<int> edge[108000];
Int ver[108000];
Int dep[108000];
bool compare(const Int &a, const Int &b){
	return dep[a] > dep[b];
}

void dfs(Int x, Int last = -1, Int d = 0){
	dep[x] = d;
	for(Int i = 0;i < edge[x].size();i++){
		if(last == edge[x][i])continue;
		dfs(edge[x][i], x, d + 1);
	}
}

int main(){
	Int m, k, p, a, b;
	cin >> m >> k >> p;
	if(k == 0){
		cout << 0 << endl;
		return 0;
	}
	for(Int i = 1;i < m;i++){
		cin >> a >> b;
		edge[a].push_back(b);
		edge[b].push_back(a);
		ver[i - 1] = i;
	}
	ver[m - 1] = m;
	dfs(1);
	sort(ver, ver + m, compare);
	m--;
	Int r = 0, sum = 0, res = 0;
	for(Int l = 0;l < m;l++){
		while(r < m && (r - l + 1) <= k && sum + dep[ver[r]] - (r - l + 1) * dep[ver[l]] <= p){
			sum += dep[ver[r++]];
		}
		if(r < l){
		    while(r <= l)sum += dep[ver[r++]];
			continue;
		}
		res = max(res, r - l);
		sum -= dep[ver[l]];
	}
	cout << res << endl;
	return 0;

}


#include<iostream>
#include<algorithm>
#include<vector>
using namespace std;
typedef long long Int;
#define MOD 1000000007
vector<int> edge[108000];
Int ver[108000];
Int dep[108000];
bool compare(const Int &a, const Int &b){
	return dep[a] > dep[b];
}

void dfs(Int x, Int last = -1, Int d = 0){
	dep[x] = d;
	for(Int i = 0;i < edge[x].size();i++){
		if(last == edge[x][i])continue;
		dfs(edge[x][i], x, d + 1);
	}
}

int main(){
	Int m, k, p, a, b;
	cin >> m >> k >> p;
	if(k == 0){
		cout << 0 << endl;
		return 0;
	}
	for(Int i = 1;i < m;i++){
		cin >> a >> b;
		edge[a].push_back(b);
		edge[b].push_back(a);
		ver[i - 1] = i;
	}
	ver[m - 1] = m;
	dfs(1);
	sort(ver, ver + m, compare);
	m--;
	Int r = 0, sum = 0, res = 0;;
	for(Int l = 0;l < m;l++){
		while(r < m && (r - l + 1) <= k && sum - (r - l + 1) * dep[l] <= p){
			sum += dep[++r];
		}
		sum -= dep[r--];
		if(r < l){r = l;continue;}
		res = max(res, (r - l + 1));
		sum -= dep[l];
	}
	cout << res << endl;
	return 0;

}


#include<iostream>
#include<algorithm>
#include<vector>
using namespace std;
typedef long long Int;
#define MOD 1000000007
vector<int> edge[108000];
Int ver[108000];
Int dep[108000];
bool compare(const Int &a, const Int &b){
	return dep[a] > dep[b];
}

void dfs(Int x, Int last = -1, Int d = 0){
	dep[x] = d;
	for(Int i = 0;i < edge[x].size();i++){
		if(last == edge[x][i])continue;
		dfs(edge[x][i], x, d + 1);
	}
}

int main(){
	Int m, k, p, a, b;
	cin >> m >> k >> p;
	if(k == 0){
		cout << 0 << endl;
		return 0;
	}
	for(Int i = 1;i < m;i++){
		cin >> a >> b;
		edge[a].push_back(b);
		edge[b].push_back(a);
		ver[i - 1] = i;
	}
	ver[m - 1] = m;
	dfs(1);
	sort(ver, ver + m, compare);
	m--;
	Int r = 0, sum = 0, res = 0;
	for(Int l = 0;l < m;l++){
		r = max(r, l);
		while(r < m && (r - l + 1) <= k && sum + dep[ver[r]] - (r - l + 1) * dep[ver[l]] <= p){
			sum += dep[ver[r++]];
		}
		if(r < l)continue;
		res = max(res, r - l);
		sum -= dep[ver[l]];
	}
	cout << res << endl;
	return 0;

}


#include<iostream>
#include<algorithm>
#include<vector>
using namespace std;
typedef long long Int;
#define MOD 1000000007
vector<int> edge[108000];
Int ver[108000];
Int dep[108000];
Int imos[108000];
bool compare(const Int &a, const Int &b){
	return dep[a] > dep[b];
}

void dfs(Int x, Int last = -1, Int d = 1){
	dep[x] = d;
	for(Int i = 0;i < edge[x].size();i++){
		if(last == edge[x][i])continue;
		dfs(edge[x][i], x, d + 1);
	}
}

int main(){
	Int m, k, p, a, b;
	cin >> m >> k >> p;
	if(k == 0){
		cout << 0 << endl;
		return 0;
	}
	for(Int i = 1;i < m;i++){
		cin >> a >> b;
		a--,b--;
		edge[a].push_back(b);
		edge[b].push_back(a);
		ver[i - 1] = i;
	}
	ver[m - 1] = m;
	dfs(0);
	sort(ver, ver + m, compare);
	for(int i = 1;i <= m;i++){
		imos[i] = imos[i - 1] + dep[ver[i - 1]];
	}
	m--;
	Int r = 0, res = 0;
	for(Int l = 0;l < m;l++){
		r = max(l, r);
		while(r < m && (r - l + 1) * dep[ver[l]] - (imos[r + 1] - imos[l])  <= p){
			r++;
		}
		r--;
		res = max(res, r - l + 1);
	}
	cout << min(k, res) << endl;
	return 0;

}


#include<iostream>
#include<algorithm>
#include<vector>
using namespace std;
typedef long long Int;
#define MOD 1000000007
vector<int> edge[108000];
Int ver[108000];
Int dep[108000];
Int imos[108000];
bool compare(const Int &a, const Int &b){
	return dep[a] > dep[b];
}

void dfs(Int x, Int last = -1, Int d = 1){
	dep[x] = d;
	for(Int i = 0;i < edge[x].size();i++){
		if(last == edge[x][i])continue;
		dfs(edge[x][i], x, d + 1);
	}
}

int main(){
	Int m, k, p, a, b;
	cin >> m >> k >> p;
	if(k == 0){
		cout << 0 << endl;
		return 0;
	}
	for(Int i = 1;i < m;i++){
		cin >> a >> b;
		a--,b--;
		edge[a].push_back(b);
		edge[b].push_back(a);
		ver[i - 1] = i;
	}
	ver[m - 1] = m;
	dfs(0);
	sort(ver, ver + m, compare);
	for(int i = 1;i <= m;i++){
		imos[i] = imos[i - 1] + dep[ver[i - 1]];
	}
	m--;
	Int r = 0, res = 0;
	for(Int l = 0;l < m;l++){
		r = max(l, r);
		while(r < m && imos[r + 1] - imos[l] - (r - l + 1) * dep[ver[l]] <= p){
			r++;
		}
		r--;
		res = max(res, r - l + 1);
	}
	cout << min(k, res) << endl;
	return 0;

}


#include<iostream>
#include<algorithm>
#include<vector>
using namespace std;
typedef long long Int;
#define MOD 1000000007
vector<int> edge[108000];
Int ver[108000];
Int dep[108000];
bool compare(const Int &a, const Int &b){
	return dep[a] > dep[b];
}

void dfs(Int x, Int last = -1, Int d = 0){
	dep[x] = d;
	for(Int i = 0;i < edge[x].size();i++){
		if(last == edge[x][i])continue;
		dfs(edge[x][i], x, d + 1);
	}
}

int main(){
	Int m, k, p, a, b;
	cin >> m >> k >> p;
	if(k == 0){
		cout << 0 << endl;
		return 0;
	}
	for(Int i = 1;i < m;i++){
		cin >> a >> b;
		edge[a].push_back(b);
		edge[b].push_back(a);
		ver[i - 1] = i;
	}
	ver[m - 1] = m;
	dfs(1);
	sort(ver, ver + m, compare);
	m--;
	Int r = 0, sum = 0, res = 0;;
	for(Int l = 0;l < m;l++){
		while(r < m && (r - l + 1) <= k && sum - (r - l + 1) * dep[l] <= p){
			sum += dep[++r];
		}
		sum -= dep[r--];
		if(r < l){r = l;continue;}
		res = max(res, (r - l + 1));
	}
	cout << res << endl;
	return 0;

}


#include<iostream>
#include<algorithm>
#include<vector>
using namespace std;
typedef long long Int;
#define MOD 1000000007
vector<int> edge[108000];
Int ver[108000];
Int dep[108000];
Int imos[108000];
bool compare(const Int &a, const Int &b){
	return dep[a] > dep[b];
}

void dfs(Int x, Int last = -1, Int d = 0){
	dep[x] = d;
	for(Int i = 0;i < edge[x].size();i++){
		if(last == edge[x][i])continue;
		dfs(edge[x][i], x, d + 1);
	}
}

int main(){
	Int m, k, p, a, b;
	cin >> m >> k >> p;
	if(k == 0){
		cout << 0 << endl;
		return 0;
	}
	for(Int i = 1;i < m;i++){
		cin >> a >> b;
		edge[a].push_back(b);
		edge[b].push_back(a);
		ver[i - 1] = i;
	}
	ver[m - 1] = m;
	dfs(1);
	sort(ver, ver + m, compare);
	for(int i = 1;i <= m;i++){
		imos[i] = imos[i - 1] + dep[ver[i - 1]];
	}
	m--;
	Int r = 0, res = 0;
	for(Int l = 0;l < m;l++){
		r = max(l, r);
		while(r < m && imos[r + 1] - imos[l] - (r - l + 1) * dep[ver[l]] <= p){
			r++;
		}
		r--;
		res = max(res, r - l + 1);
	}
	cout << min(k, res) << endl;
	return 0;

}


#include<cstring>
#include<cstdlib>
#include<cstdio>
#include<cmath>
#include<algorithm>
#include<map>
#include<set>
#include<string>
#include<vector>
#define pb push_back
#define rep(i,j,k) for(int i=(j);i<=(int)k;i++)
#define per(i,j,k) for(int i=(j);i>=(int)k;i--)
#define lowbit(x) ((x)&(-(x)))
#define fi first
#define se second
#define pii pair<int,int>
#define VI vector<int>
#define S(x) x.size()
using namespace std;
typedef long long LL;
typedef double db;
const int N=110000;int n;LL wa,mo;LL sum[N];LL res[N];
vector<int>p[N];int num[N],dep[N];
void dfs(int x,int fa){dep[x]=dep[fa]+1;num[dep[x]]++;rep(i,0,p[x].size()-1)if(p[x][i]!=fa)dfs(p[x][i],x);}
inline LL calc(int l,int r){
	return (res[r]-res[l-1])-(sum[r]-sum[l-1])*1ll*(n-r);
}
inline bool ck(int l,int r){
	return (calc(l,r)<=mo)&&(sum[r]-sum[l-1]<=wa);
}
int main(){
	scanf("%d%I64d%I64d",&n,&wa,&mo);LL ans=0;
	rep(i,1,n-1){
		int a,b;scanf("%d%d",&a,&b);p[a].pb(b);p[b].pb(a);
	}
	dfs(1,0);
	rep(i,1,n)sum[i]=num[i]+sum[i-1];
	rep(i,1,n)res[i]=res[i-1]+num[i]*1ll*(n-i);
	rep(i,2,n){
		int l=2;int r=i;int rp=i+1;
		while(l<r){
			int mid=(l+r)>>1;
			if(ck(mid,i))rp=mid,r=mid;
			else l=mid+1;
		}
		if(ck(l,i))rp=l;
		if(rp==i+1)ans=max(ans,wa);else
		ans=max(ans,sum[i]-sum[rp-1]+(rp!=2)*min(wa-sum[i]+sum[rp-1],(mo-calc(rp,i))/(i-(rp-1))));
	}
	printf("%I64d\n",ans);
	return 0;
}


#include<cstring>
#include<cstdlib>
#include<cstdio>
#include<cmath>
#include<algorithm>
#include<map>
#include<set>
#include<string>
#include<vector>
#define pb push_back
#define rep(i,j,k) for(int i=(j);i<=(int)k;i++)
#define per(i,j,k) for(int i=(j);i>=(int)k;i--)
#define lowbit(x) ((x)&(-(x)))
#define fi first
#define se second
#define pii pair<int,int>
#define VI vector<int>
#define S(x) x.size()
using namespace std;
typedef long long LL;
typedef double db;
const int N=110000;int water,cot,n;
vector<int>p[N];int num[N],dep[N];
void dfs(int x,int fa){
	dep[x]=dep[fa]+1;num[dep[x]]++;
	rep(i,0,p[x].size()-1)if(p[x][i]!=fa)dfs(p[x][i],x);
}
int relax(int a,int b){
	if(!b)return a;return max(a/b,0);
}
int main(){
	scanf("%d%d%d",&n,&water,&cot);
	rep(i,1,n-1){
		int a,b;scanf("%d%d",&a,&b);p[a].pb(b);p[b].pb(a);
	}
	dfs(1,0);int ans=0;
	int now=0;int l=n+1;int sum=0;
	per(i,n,2){
		now-=sum;sum-=num[i+1];
		while(l>2&&sum+num[l-1]<=water&&now+1ll*num[l-1]*(i-l+1)<=cot){
			l--;sum+=num[l];now+=num[l]*(i-l);
		}
		if(l==2)ans=max(ans,sum);
		else ans=max(ans,relax(cot-sum,i-l+1)+sum);
	}
	printf("%d\n",min(ans,water));
	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);
            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;
LL costcum[lim];

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];

        costcum[maxhei+1]=0;
        for(i=maxhei;i>=2;i--)
            costcum[i]=(LL)(maxhei-i)*(LL)hei[i]+costcum[i+1];

        int j=maxhei;
        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];
            int cost= costcum[j+1]-costcum[i+1]-(LL)(maxhei-i)*(LL)totalnode;

            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);
        }
        print1(ans);
    }
    return 0;
}