#include<iostream>
#include<cstdio>
#include<vector>
using namespace std;
int main(){
  int n, k; scanf("%d %d",&n ,&k);
  int x = 1, y = k + 1;
  bool flag = false;
  for(int i = 1; i <= k + 1; i++){
    if(!flag) printf("%d ", x++);
    else printf("%d ", y--);
    flag = !flag;
  }
  for(int i = k + 2; i <= n; i++){
    printf("%d ", i);
  }
  return 0;
}


#include<iostream>
#include<cstdio>
using namespace std;
int main(){
  int n, k; scanf("%d %d",&n ,&k);
  int x = 1, cnt = 0, stop;
  for(int i = 1; i <= n; i++){
    printf("%d ", x);
    if(cnt == k) stop = i;
    if(cnt < k) x += i;
    else x += stop;
    cnt++;
  }
  return 0;
}


#include<cstdio>
#include<iostream>
#include<cstring>
#include<algorithm>
#include<cmath>
#include<queue>
#include<set>
#include<map>
using namespace std;
typedef long long ll;
const int inf=1<<29;
const ll Maxn=1e6;
const double pi=3.1415926536;

int n,k;
int a[Maxn];

bool cmp(int x,int y){
	return x>y;
}

int main(){
	scanf("%d %d",&n,&k);
		a[1]=1;
		a[2]=n;
		for(int i=3;i<=n;i++){
			if(i%2==1) a[i]=a[i-2]+1;
			else a[i]=a[i-2]-1;
		}
		if(2*k-2<=n) sort(a+2*k-1,a+1+n,cmp);
		for(int i=1;i<n;i++) printf("%d ",a[i]);
		printf("%d",a[n]);
}


#include<cstdio>
#include<iostream>
#include<cstring>
#include<algorithm>
#include<cmath>
#include<queue>
#include<set>
#include<map>
using namespace std;
typedef long long ll;
const int inf=1<<29;
const ll Maxn=1e6;
const double pi=3.1415926536;

int n,k;
int a[Maxn];

bool cmp(int x,int y){
	return x>y;
}

int main(){
	scanf("%d %d",&n,&k);
		a[1]=1;
		a[2]=n;
		for(int i=3;i<=n;i++){
			if(i%2==1) a[i]=a[i-2]+1;
			else a[i]=a[i-2]-1;
		}
		sort(a+k,a+1+n,cmp);
		if(a[k-1]==a[k]+1) sort(a+k,a+1+n);
		for(int i=1;i<n;i++) printf("%d ",a[i]);
		printf("%d",a[n]);
}


#include<cstdio>
#include<iostream>
#include<cstring>
#include<algorithm>
#include<cmath>
#include<queue>
#include<set>
#include<map>
using namespace std;
typedef long long ll;
const int inf=1<<29;
const ll Maxn=1e6;
const double pi=3.1415926536;

int n,k;
int a[Maxn];

bool cmp(int x,int y){
	return x>y;
}

int main(){
	scanf("%d %d",&n,&k);
		a[1]=1;
		a[2]=n;
		for(int i=3;i<=n;i++){
			if(i%2==1) a[i]=a[i-2]+1;
			else a[i]=a[i-2]-1;
		}
		sort(a+1+k,a+1+n,cmp);
		for(int i=1;i<n;i++) printf("%d ",a[i]);
		printf("%d",a[n]);
}


#include<cstdio>
#include<iostream>
#include<cstring>
#include<algorithm>
#include<cmath>
#include<queue>
#include<set>
#include<map>
using namespace std;
typedef long long ll;
const int inf=1<<29;
const ll Maxn=1e6;
const double pi=3.1415926536;

int n,k;
int a[Maxn];

bool cmp(int x,int y){
	return x>y;
}

int main(){
	scanf("%d %d",&n,&k);
		a[1]=1;
		a[2]=n;
		for(int i=3;i<=n;i++){
			if(i%2==1) a[i]=a[i-2]+1;
			else a[i]=a[i-2]-1;
		}
		sort(a+k,a+1+n,cmp);
		for(int i=1;i<n;i++) printf("%d ",a[i]);
		printf("%d",a[n]);
}


#include<cstdio>
#include<iostream>
#include<cstring>
#include<algorithm>
#include<cmath>
#include<queue>
#include<set>
#include<map>
using namespace std;
typedef long long ll;
const int inf=1<<29;
const ll Maxn=1e6;
const double pi=3.1415926536;

int n,k;
int a[Maxn];

bool cmp(int x,int y){
	return x>y;
}

int main(){
	scanf("%d %d",&n,&k);
		a[1]=1;
		a[2]=n;
		for(int i=3;i<=n;i++){
			if(i%2==1) a[i]=a[i-2]+1;
			else a[i]=a[i-2]-1;
		}
		sort(a+2*k-1,a+1+n,cmp);
		for(int i=1;i<n;i++) printf("%d ",a[i]);
		printf("%d",a[n]);
}


// Example program
#include <bits/stdc++.h>

using namespace std;

typedef long long int ll;

int main()
{
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    ll n, m;
    cin >> n >> m;
    ll i = 1;
    bool b = false;
    while (i <= n)
    {
        if (m > 1)
        {
            if (!b)
            {
                cout << i << " ";
                i++;
                b = true;
            }
            else
            {
                cout << n << " ";
                n--;
                b = false;
            }
            m--;
        }
        else
        {
            if (!b)
            {
                cout << i << " ";
                i++;
            }
            else
            {
                cout << n << " ";
                n--;
            }
        }
    }
}


// Example program
#include <bits/stdc++.h>

using namespace std;

typedef long long int ll;

int main()
{
    ll n, m;
    cin >> n >> m;
    ll i = 1;
    bool b = false;
    while (i <= n)
    {
        if (m > 1)
        {
            if (!b)
            {
                cout << i << " ";
                i++;
                b = true;
            }
            else
            {
                cout << n << " ";
                n--;
                b = false;
            }
            m--;
        }
        else
        {
            if (!b)
            {
                cout << i << " ";
                i++;
            }
            else
            {
                cout << n << " ";
                n--;
            }
        }
    }
}


#include<bits/stdc++.h>
using namespace std;
const int N =2e5+5;
const long long M = (long long)1e9+7;
#define     ll      long long
#define     ull     unsigned long long
int Int() {
    int x;
    scanf("%d",&x);
    return x;
}
ll Long() {
    ll x;
    scanf("%lld",&x);
    return x;
}
void Char(char* ch) {
    scanf("%s",ch);
}
template<typename t>inline t abs(t a) {
    if(a>=0)
        return a;
    return -a;
}
template<typename T> inline T modpow(T b, T p, T Mod) {
    T res  = 1;
    while(p) {
        if(p&1) {
            res *= b ;
            res %= Mod ;
        }
        b *= b;
        b %= Mod;
        p >>= 1;
    }
    return res ;
}

template<typename T> inline T ModInv(T b, T Mod) {
    return modpow(b, Mod - 2, Mod );
}

template<typename T> inline T pwr(T b, T p) {
    T res  = 1;
    while(p) {
        if(p&1) {
            res *= b ;
        }
        b *= b;
        p >>= 1;
    }
    return res ;
}

template<typename T> inline T gcd(T a, T b) {
    if(b==0)
        return a;
    return gcd(b, a%b);
}

template <typename T> inline void Int(T &n) {
    n = 0;
    int f = 1;
    register int ch = getchar();
    for (; !isdigit(ch); ch = getchar())
        if (ch == '-')
            f = -1;
    for (; isdigit(ch); ch = getchar())
        n = (n << 3) + (n << 1) + ch - '0';
    n = n * f;
}
template<typename T, typename U> inline void Int(T &a, U &b) {
    Int(a);
    Int(b);
}
template<typename T, typename U, typename W> inline void Int(T &a, U &b, W &c) {
    Int(a,b);
    Int(c);
}
template<typename T, typename U, typename W,typename X> inline void Int(T &a, U &b, W &c, X &d) {
    Int(a,b,c);
    Int(d);
}
vector<int> Unique(vector<int> v) {
    sort(v.begin(), v.end());
    v.erase(unique(v.begin(), v.end()),v.end());
    return v;
}
///error///
#define error(args...) {vector<string>_v=split(#args,',');err(_v.begin(),args);cout<<endl;}
vector<string> split(const string &s,char c) {
    vector<string>v;
    stringstream ss(s);
    string x;
    while(getline(ss,x,c))
        v.emplace_back(x);
    return move(v);
}

void err(vector<string>::iterator it) {}
template<typename T,typename... Args>
void err(vector<string>::iterator it,T a,Args...args) {
    cout<<it->substr((*it)[0]==' ',it->length())<< " = " << a << " ";
    err(++it,args...);
}
///This DEBUGGER-tool need c++11///
#define     Int         Int()
#define     Long        Long()
#define     pii         pair<int,int>
#define     ff          first
#define     ss          second
#define     pb		push_back
#define     all(x)      x.begin(),x.end()
#define     mem(a)      memset(a,0,sizeof a)
#define     memn(a)     memset(a,-1,sizeof a)

int freq[N];
int main() {
    int n = Int , k = Int ;
    printf("1 ");
    int x = 1 ;
    freq[1] = 1 ;
    int f = k + 1 ;
    for(int i = 1 ; i < f and k > 1 ; i++){
    	if( x + k > f){
    			printf("%d ",x - k);
    			x -= k ;
    			freq[x] = 1 ;
    			k--;
    	}
    	else {
    			printf("%d ",x + k);
    			x += k ;
    			freq[x] = 1 ;
    			k--;
    	}
    	//error(x , k)
    }
    for(int i = 1 ; i <= n ; i++){
    	if(!freq[i])printf("%d ",i);
    }
    return 0;
}


#include<bits/stdc++.h>
using namespace std;
const int N =2e5+5;
const long long M = (long long)1e9+7;
#define     ll      long long
#define     ull     unsigned long long
int Int() {
    int x;
    scanf("%d",&x);
    return x;
}
ll Long() {
    ll x;
    scanf("%lld",&x);
    return x;
}
void Char(char* ch) {
    scanf("%s",ch);
}
template<typename t>inline t abs(t a) {
    if(a>=0)
        return a;
    return -a;
}
template<typename T> inline T modpow(T b, T p, T Mod) {
    T res  = 1;
    while(p) {
        if(p&1) {
            res *= b ;
            res %= Mod ;
        }
        b *= b;
        b %= Mod;
        p >>= 1;
    }
    return res ;
}

template<typename T> inline T ModInv(T b, T Mod) {
    return modpow(b, Mod - 2, Mod );
}

template<typename T> inline T pwr(T b, T p) {
    T res  = 1;
    while(p) {
        if(p&1) {
            res *= b ;
        }
        b *= b;
        p >>= 1;
    }
    return res ;
}

template<typename T> inline T gcd(T a, T b) {
    if(b==0)
        return a;
    return gcd(b, a%b);
}

template <typename T> inline void Int(T &n) {
    n = 0;
    int f = 1;
    register int ch = getchar();
    for (; !isdigit(ch); ch = getchar())
        if (ch == '-')
            f = -1;
    for (; isdigit(ch); ch = getchar())
        n = (n << 3) + (n << 1) + ch - '0';
    n = n * f;
}
template<typename T, typename U> inline void Int(T &a, U &b) {
    Int(a);
    Int(b);
}
template<typename T, typename U, typename W> inline void Int(T &a, U &b, W &c) {
    Int(a,b);
    Int(c);
}
template<typename T, typename U, typename W,typename X> inline void Int(T &a, U &b, W &c, X &d) {
    Int(a,b,c);
    Int(d);
}
vector<int> Unique(vector<int> v) {
    sort(v.begin(), v.end());
    v.erase(unique(v.begin(), v.end()),v.end());
    return v;
}
///error///
#define error(args...) {vector<string>_v=split(#args,',');err(_v.begin(),args);cout<<endl;}
vector<string> split(const string &s,char c) {
    vector<string>v;
    stringstream ss(s);
    string x;
    while(getline(ss,x,c))
        v.emplace_back(x);
    return move(v);
}

void err(vector<string>::iterator it) {}
template<typename T,typename... Args>
void err(vector<string>::iterator it,T a,Args...args) {
    cout<<it->substr((*it)[0]==' ',it->length())<< " = " << a << " ";
    err(++it,args...);
}
///This DEBUGGER-tool need c++11///
#define     Int         Int()
#define     Long        Long()
#define     pii         pair<int,int>
#define     ff          first
#define     ss          second
#define     pb		push_back
#define     all(x)      x.begin(),x.end()
#define     mem(a)      memset(a,0,sizeof a)
#define     memn(a)     memset(a,-1,sizeof a)

int freq[N];
int main() {
    int n = Int , k = Int ;
    int x = 1 , y = k + 1;
    freq[1] = 1 ;
    int f = k + 1 ;
    for(int i = 1 ; i <= f ; i++){
    	if(i & 1)printf("%d ",x),x++,freq[x - 1] = 1;
    	else printf("%d ",y),y-- , freq[y + 1] = 1;
    }
    for(int i = 1 ; i <= n ; i++){
    	if(!freq[i])printf("%d ",i);
    }
    return 0;
}


#include<bits/stdc++.h>
using namespace std;
const int N =2e5+5;
const long long M = (long long)1e9+7;
#define     ll      long long
#define     ull     unsigned long long
int Int() {
    int x;
    scanf("%d",&x);
    return x;
}
ll Long() {
    ll x;
    scanf("%lld",&x);
    return x;
}
void Char(char* ch) {
    scanf("%s",ch);
}
template<typename t>inline t abs(t a) {
    if(a>=0)
        return a;
    return -a;
}
template<typename T> inline T modpow(T b, T p, T Mod) {
    T res  = 1;
    while(p) {
        if(p&1) {
            res *= b ;
            res %= Mod ;
        }
        b *= b;
        b %= Mod;
        p >>= 1;
    }
    return res ;
}

template<typename T> inline T ModInv(T b, T Mod) {
    return modpow(b, Mod - 2, Mod );
}

template<typename T> inline T pwr(T b, T p) {
    T res  = 1;
    while(p) {
        if(p&1) {
            res *= b ;
        }
        b *= b;
        p >>= 1;
    }
    return res ;
}

template<typename T> inline T gcd(T a, T b) {
    if(b==0)
        return a;
    return gcd(b, a%b);
}

template <typename T> inline void Int(T &n) {
    n = 0;
    int f = 1;
    register int ch = getchar();
    for (; !isdigit(ch); ch = getchar())
        if (ch == '-')
            f = -1;
    for (; isdigit(ch); ch = getchar())
        n = (n << 3) + (n << 1) + ch - '0';
    n = n * f;
}
template<typename T, typename U> inline void Int(T &a, U &b) {
    Int(a);
    Int(b);
}
template<typename T, typename U, typename W> inline void Int(T &a, U &b, W &c) {
    Int(a,b);
    Int(c);
}
template<typename T, typename U, typename W,typename X> inline void Int(T &a, U &b, W &c, X &d) {
    Int(a,b,c);
    Int(d);
}
vector<int> Unique(vector<int> v) {
    sort(v.begin(), v.end());
    v.erase(unique(v.begin(), v.end()),v.end());
    return v;
}
///error///
#define error(args...) {vector<string>_v=split(#args,',');err(_v.begin(),args);cout<<endl;}
vector<string> split(const string &s,char c) {
    vector<string>v;
    stringstream ss(s);
    string x;
    while(getline(ss,x,c))
        v.emplace_back(x);
    return move(v);
}

void err(vector<string>::iterator it) {}
template<typename T,typename... Args>
void err(vector<string>::iterator it,T a,Args...args) {
    cout<<it->substr((*it)[0]==' ',it->length())<< " = " << a << " ";
    err(++it,args...);
}
///This DEBUGGER-tool need c++11///
#define     Int         Int()
#define     Long        Long()
#define     pii         pair<int,int>
#define     ff          first
#define     ss          second
#define     pb		push_back
#define     all(x)      x.begin(),x.end()
#define     mem(a)      memset(a,0,sizeof a)
#define     memn(a)     memset(a,-1,sizeof a)

int freq[N];
int main() {
    int n = Int , k = Int ;
    printf("1 ");
    int x = 1 ;
    freq[1] = 1 ;
    int f = k + 1 ;
    for(int i = 1 ; i < f and k > 1 ; i++){
    	if( x + k > f){
    			if(freq[x - k] == 0){
    				printf("%d ",x - k);
    			    x -= k ;
    			    freq[x] = 1 ;
    			}
    	}
    	else {
    			if(freq[x + k] == 0){
    				printf("%d ",x + k);
    			    x += k ;
    			    freq[x] = 1 ;
    			}
    	}
    	k--;
    }
    for(int i = 1 ; i <= n ; i++){
    	if(!freq[i])printf("%d ",i);
    }
    return 0;
}


#include <bits/stdc++.h>
#define ll long long
using namespace std;
const int N=2e5+5,OO=0x3f3f3f3f;
int n,k;
bool vis[N];

int main()
{
    cin.tie(0);
    cin.sync_with_stdio(0);
    cin>>n>>k;
    cout<<1<<" ";
    int i=1;
    vis[i]=1;
    bool f=1;
    while(k){
        if(f) cout<<i+k<<" ",vis[i+k]=1,i=i+k;
        else cout<<i-k<<" ",vis[i-k]=1,i=i-k;
        f=!f;
        k--;
    }
    for(int j=1;j<=n;j++) if(!vis[j]) cout<<j<<" ";

    return 0;
}


#include <bits/stdc++.h>
#define ll long long
using namespace std;
const int N=2e5+5,OO=0x3f3f3f3f;
int n,k;
int vis[N];

int main()
{
    cin.tie(0);
    cin.sync_with_stdio(0);
    cin>>n>>k;
    cout<<1<<" ";
    int i=1;
    vis[i]=1;
    while(k){
        cout<<i+k<<" ";
        vis[i+k]=1;
        k--;
    }
    for(;i<=n;i++) if(!vis[i]) cout<<i<<" ";

    return 0;
}


#include <iostream>
#include <cstdio>
#include <cstdlib>
#define ll long long int

using namespace std;

ll n,k,N[100005],dist[100005];

int main()
{
    ios::sync_with_stdio(false), cin.tie(0), cout.tie(0);

    cin>> n >> k;

    int num=1;
    N[1] = 1;
    cout<< 1 << " ";

    for(; k>0 ; k--){
        if(num-k>0 && N[num-k]==0){
            cout<< num-k << " ";
            num = num - k;
            N[num] = 1;
        }
        else if(num+k<=n && N[num+k]==0){
            cout<< num+k << " ";
            num = num+k;
            N[num] = 1;
        }
    }

    for(int i=1;i<=n;i++){
        if(N[i]==0){
            cout<< i << " ";
        }
    }
    cout<< endl;

    return 0;
}


#include <iostream>
#include <cstdio>
#include <cstdlib>
#define ll long long int

using namespace std;

ll n,k,N[100005],dist[100005];

int main()
{
    ios::sync_with_stdio(false), cin.tie(0), cout.tie(0);

    cin>> n >> k;
    for(int i=1;i<=n;i++){
        N[i]=i;
        if(i<=k){ dist[i]=i; }
    }

    int j=1;
    for(int i=2;i<=n;i++){
        N[i] = abs((N[i]-N[i-1])-dist[j]) + N[i];
        j++;
        if(j==k+1){ j=1; }
    }

    for(int i=1;i<=n;i++){
        char c = i==n? '\n':' ';
        cout<< N[i] << c;
    }

    return 0;
}


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

//Think twice, code once =)

int main(){

    std::ios::sync_with_stdio(0);
    std::cin.tie(0);
    std::cout.tie(0);

 	int n, k;
 	cin >> n >> k;
 	int i = 1, j = n;
 	while(--k != 0 && i != j){
 		cout << i++ << " " << j-- << " ";
 	}
 	while(j >= i)
 		cout << j-- << " ";
    return 0;
}


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

//Think twice, code once =)

int main(){

    std::ios::sync_with_stdio(0);
    std::cin.tie(0);
    std::cout.tie(0);

 	int n, k;
 	cin >> n >> k;
 	int i = 1, j, prev = 0;
 	for(j = 0; j < k - 1; ++j){
 		cout << i << " ";
 		prev = i;
 		i += i;
 	}
 	while(j++ < n)
 		cout << ++i << " ";
    return 0;
}


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

//Think twice, code once =)

int main(){

    std::ios::sync_with_stdio(0);
    std::cin.tie(0);
    std::cout.tie(0);

 	int n, k;
 	cin >> n >> k;
 	int i = 1, j = n;
 	if(k == 1){
 		for(int l = 1; l <= n; ++l)
 			cout << l << " ";
 		return 0;
 	}
 	bool ok = k & 1;
 	while(--k >= 0 && i != j){
  		if(!k){
 			while(i <= j)
 				cout << i++ << " ";
 			return 0;
 		}
 		cout << i++ << " " << j-- << " ";
 		--k;
 	}
 		while(j >= i)
 			cout << j-- << " ";
 	 return 0;
}


#include <iostream>
#include <bits/stdc++.h>
#include <math.h>
using namespace std;
typedef long long int ll;
typedef long double dl;
#define PI  3.14159265358979323846
#define M   1000000009
ll fast(ll n,ll a,ll m)
{
    if(n==0)
        return 1;
    else if(n==1)
        return a;
    else
    {
        ll r=fast(n/2,a,m);
        if(n%2==0)
        {
            return (((r%m)*(r%m))%m);
        }
        else
        {
            return (((((r%m)*a)%m)*r)%m);
        }

    }
}
dl sqt(dl n)
{
    dl lo=0.0,hi=100000000000.0;
    dl mid,ans;
    while(hi-lo>=0.0000001)
    {
        mid=(lo+hi)/2;
        dl r=mid*mid;
        if(r<=n)
        {
            ans=mid;
            lo=mid;
        }
        else
        {
            hi=mid;
        }
    }
    return ans;
}
int main()
{
    ll n,K,i;
    cin>>n>>K;
    if(K==1)
    {

        for(i=1;i<=n;i++)
            cout<<i<<" ";
    }
    else
    {
        if(K%2==0)
        {
            ll p=n;
            for(i=1;i<=(K/2);i++)
            {
                cout<<i<<" "<<p<<" ";
                p--;
            }
            for(i=p;i>=(K/2)+1;i--)
            {
                cout<<i<<" ";
            }
        }
        else
        {
            ll d=K/2;
            ll cnt=n;
            for(i=1;i<=d;i++)
            {
                cout<<i<<" "<<cnt<<" ";
                cnt--;
            }
            for(i=d+1;i<=cnt;i++)
                cout<<i<<" ";

        }
    }
}


#include <iostream>
#include <bits/stdc++.h>
#include <math.h>
using namespace std;
typedef long long int ll;
typedef long double dl;
#define PI  3.14159265358979323846
#define M   1000000009
ll fast(ll n,ll a,ll m)
{
    if(n==0)
        return 1;
    else if(n==1)
        return a;
    else
    {
        ll r=fast(n/2,a,m);
        if(n%2==0)
        {
            return (((r%m)*(r%m))%m);
        }
        else
        {
            return (((((r%m)*a)%m)*r)%m);
        }

    }
}
dl sqt(dl n)
{
    dl lo=0.0,hi=100000000000.0;
    dl mid,ans;
    while(hi-lo>=0.0000001)
    {
        mid=(lo+hi)/2;
        dl r=mid*mid;
        if(r<=n)
        {
            ans=mid;
            lo=mid;
        }
        else
        {
            hi=mid;
        }
    }
    return ans;
}
int main()
{
    ll n,K,i;
    cin>>n>>K;
    if(K==1)
    {

        for(i=1;i<=n;i++)
            cout<<i<<" ";
    }
    else
    {
        if(K%2==0)
        {
            ll p=n;
            for(i=1;i<=(K/2);i++)
            {
                cout<<i<<" "<<p<<" ";
                p--;
            }
            for(i=p;i>=K;i--)
            {
                cout<<i<<" ";
            }
        }
        else
        {
            ll d=K/2;
            ll cnt=n;
            for(i=1;i<=d;i++)
            {
                cout<<i<<" "<<cnt<<" ";
                cnt--;
            }
            for(i=d+1;i<=cnt;i++)
                cout<<i<<" ";

        }
    }
}


#include<cstdio>
#include<vector>
#include<algorithm>
#define N 100005
#define P pair<int,int>
inline int read(){
	int x=0,f=0;
	register char ch=getchar();
	for(;ch<48||ch>57;ch=getchar())f|=ch=='-';
	for(;ch>47&&ch<58;ch=getchar())
	x=(x<<1)+(x<<3)+(ch^48);
	return f?~x+1:x;
}
using namespace std;
vector<P>num[30];
int a[30][N],l[N],r[N],q[N],n,m;
inline int check()
{
	for(int i=0;i<m;++i)
	{
		for(int j=0;j<30;++j)
		{
			if(q[i]&1<<j)continue;
			if(a[j][r[i]]-a[j][l[i]-1]==r[i]-l[i]+1)return 1;
		}
	}
	return 0;
}
int main()
{
	n=read(),m=read();
	for(int i=0;i<m;++i)
	{
		l[i]=read(),r[i]=read(),q[i]=read();int t=q[i];
		for(int j=0;t;t>>=1,++j)if(t&1)
		num[j].push_back(P(l[i],1)),num[j].push_back(P(r[i]+1,-1));
	}for(int i=0;i<30;++i)
	{
		sort(num[i].begin(),num[i].end());
		int now=0;vector<P>::iterator it=num[i].begin();
		for(int j=1;j<=n;++j)
		{
			for(;it!=num[i].end()&&it->first==j;++it)now+=it->second;
			a[i][j]=a[i][j-1]+(now>0);
		}
	}
	if(check())puts("NO");
	else
	{
		puts("YES");
		for(int i=0;i<30;++i)
		for(int j=n;j;--j)
		a[i][j]-=a[i][j-1];
		for(int j=1;j<=n;++j)
		{
			int x=0;
			for(int i=0;i<30;++i)
			if(a[i][j])x+=1<<i;
			printf("%d ",x);
		}
	}
	return 0;
}


#include<stdio.h>
int n,k;
int main(){
	scanf("%d %d",&n,&k);
	for(int i=1;i<n-k;++i)
		printf("%d ",i);
	int l,r;
	for(l=n-k,r=n;r>l;++l,--r)printf("%d %d ",l,r);
	if(l==r)
		printf("%d ",l);
	return 0;
}


 #include<bits/stdc++.h>
 using namespace std ;
 long long n , i , k , t = 1 , z;
 int main()
 {
     ios_base::sync_with_stdio(0);cin.tie(NULL);cout.tie(NULL);
     cin>>n>>k;
     cout<<t<<" ";
     for(i = 2 ; i <= n ; i ++)
     {
         if(k > 1)
         {
             if(i % 2 == 1)
             cout<<t<<" " , t ++ ;
             else
             cout<<n - t + 1<<" ";
             k -- ;
         }
         else{
                if(i % 2 == 1 && z == 0)
                {
                    k = -1;
                    t = n - t + 1 ;
                }
                t += k ;
            cout<<t<<" ";
                z = 1 ;
         }
     }
     return 0 ;
 }


 #include<bits/stdc++.h>
 using namespace std ;
 long long n , i , k , t = 1 ;
 int main()
 {
     ios_base::sync_with_stdio(0);cin.tie(NULL);cout.tie(NULL);
     cin>>n>>k;
     cout<<t<<" ";
     for(i = 2 ; i <= n ; i ++)
     {
         if(k > 1)
         {
             if(i % 2 == 1)
             cout<<t<<" " , t ++ ;
             else
             cout<<n - t + 1<<" ";
             k -- ;
         }
         else{
                if(k == 1 && i % 2 == 1)t = n - t + 1 , k = -1 ;
                t += k ;
            cout<<t<<" ";
         }
     }
     return 0 ;
 }


 #include<bits/stdc++.h>
 using namespace std ;
 long long n , i , k , t = 1 , z;
 int main()
 {
     ios_base::sync_with_stdio(0);cin.tie(NULL);cout.tie(NULL);
     cin>>n>>k;
     cout<<t<<" ";
     for(i = 2 ; i <= n ; i ++)
     {
         if(k > 1)
         {
             if(i % 2 == 1)
             t ++ , cout<<t<<" " ;
             else
             cout<<n - t + 1<<" ";
             k -- ;
         }
         else{
                if(i % 2 == 1 && z == 0)
                {
                    k = -1;
                    t = n - t + 1 ;
                }
                t += k ;
            cout<<t<<" ";
                z = 1 ;
         }
     }
     return 0 ;
 }


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

#define debug1(x)		  cout<<x<<endl
#define debug2(x,y)       cout<<x<<"   "<<y<<endl
#define debug3(x,y,z)     cout<<x<<"   "<<y<<"   "<<z<<endl
#define debug4(x,y,z,xy)  cout<<x<<"   "<<y<<"   "<<z<<"   "<<xy<<endl

#define sl(x) scanf("%lld",&x)
#define sll(x,y) scanf("%lld%lld",&x,&y)
#define slll(x,y,z) scanf("%lld%lld%lld",&x,&y,&z)
#define pl(x) printf("%lld\n",x)
#define pb(x) push_back(x)
#define mp(x,y) make_pair(x,y)
#define ff first
#define ss second
#define MAX 1000005
#define mod 1000000007

ll vis[MAX];
int main(){
     ll diff,n,i,k;
     cin>>n>>k;
     if(k==1){
          for(i=1;i<=n;i++){
               cout<<i<<" ";
          }
          return 0;
     }
     if(n==1){
          cout<<"1\n";
          return 0;
     }

     cout<<"1 ";
     ll s=1;
     vis[1]=1;
     while(1){
          if((s+k)>n) s=s-k;
          else s=s+k;
          if(vis[s]) s-=2*k;
          vis[s]=1;
          cout<<s<<" ";
          k--;
          if(k==1) break;
     }

     for(i=1;i<=n;i++){
          if(!vis[i]) cout<<i<<" ";
     }

}


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

#define debug1(x)		  cout<<x<<endl
#define debug2(x,y)       cout<<x<<"   "<<y<<endl
#define debug3(x,y,z)     cout<<x<<"   "<<y<<"   "<<z<<endl
#define debug4(x,y,z,xy)  cout<<x<<"   "<<y<<"   "<<z<<"   "<<xy<<endl

#define sl(x) scanf("%lld",&x)
#define sll(x,y) scanf("%lld%lld",&x,&y)
#define slll(x,y,z) scanf("%lld%lld%lld",&x,&y,&z)
#define pl(x) printf("%lld\n",x)
#define pb(x) push_back(x)
#define mp(x,y) make_pair(x,y)
#define ff first
#define ss second
#define MAX 1000005
#define mod 1000000007

ll vis[MAX];
int main(){
     ll diff,n,i,k;
     cin>>n>>k;
     if(k==1){
          for(i=1;i<=n;i++){
               cout<<i<<" ";
          }
          return 0;
     }

     ll st=1,ed=k+1;
     for(i=0;i<=k;i++){
          if(i%2==0){
               vis[st]=1;
               cout<<st<<" ";
               st++;
          }else{
               vis[ed]=1;
               cout<<ed<<" ";
               ed--;
          }
     }

     for(i=1;i<=n;i++){
          if(!vis[i]) cout<<i<<" ";
     }

}


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

#define debug1(x)		  cout<<x<<endl
#define debug2(x,y)       cout<<x<<"   "<<y<<endl
#define debug3(x,y,z)     cout<<x<<"   "<<y<<"   "<<z<<endl
#define debug4(x,y,z,xy)  cout<<x<<"   "<<y<<"   "<<z<<"   "<<xy<<endl

#define sl(x) scanf("%lld",&x)
#define sll(x,y) scanf("%lld%lld",&x,&y)
#define slll(x,y,z) scanf("%lld%lld%lld",&x,&y,&z)
#define pl(x) printf("%lld\n",x)
#define pb(x) push_back(x)
#define mp(x,y) make_pair(x,y)
#define ff first
#define ss second
#define MAX 1000005
#define mod 1000000007

ll vis[MAX];
int main(){
     ll diff,n,i,k;
     cin>>n>>k;
     if(k==1){
          for(i=1;i<=n;i++){
               cout<<i<<" ";
          }
          return 0;
     }
     if(n==1){
          cout<<"1\n";
          return 0;
     }

     cout<<"1 ";
     ll s=1;
     vis[1]=1;
     while(1){
          if((s+k)>n) s=s-k;
          else s=s+k;
          if(vis[s]) s-=2*k;
          vis[s]=1;
          cout<<s<<" ";
          k--;
          if(k==0) break;
     }

     for(i=1;i<=n;i++){
          if(!vis[i]) cout<<i<<" ";
     }

}


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

#define debug1(x)		  cout<<x<<endl
#define debug2(x,y)       cout<<x<<"   "<<y<<endl
#define debug3(x,y,z)     cout<<x<<"   "<<y<<"   "<<z<<endl
#define debug4(x,y,z,xy)  cout<<x<<"   "<<y<<"   "<<z<<"   "<<xy<<endl

#define sl(x) scanf("%lld",&x)
#define sll(x,y) scanf("%lld%lld",&x,&y)
#define slll(x,y,z) scanf("%lld%lld%lld",&x,&y,&z)
#define pl(x) printf("%lld\n",x)
#define pb(x) push_back(x)
#define mp(x,y) make_pair(x,y)
#define ff first
#define ss second
#define MAX 1000005
#define mod 1000000007

ll vis[MAX];
int main(){
     ll diff,n,i,k;
     cin>>n>>k;
     if(k==1){
          for(i=1;i<=n;i++){
               cout<<i<<" ";
          }
          return 0;
     }

     cout<<"1 ";
     ll s=1;
     vis[1]=1;
     while(1){
          if((s+k)>n) s=s-k;
          else s=s+k;

          vis[s]=1;
          cout<<s<<" ";
          k--;
          if(k==1) break;
     }

     for(i=1;i<=n;i++){
          if(!vis[i]) cout<<i<<" ";
     }

}


#include <bits/stdc++.h>
using namespace std;
#define all(v) ((v).begin()), ((v).end())
#define s(n) scanf("%d", &n)
#define sc(n) scanf("%c", &n)
#define sl(n) scanf("%lld", &n)
#define sf(n) scanf("%lf", &n)
#define ss(n) scanf("%s", n)
#define INF (int)1e9
#define EPS 1e-9
#define bitcount __builtin_popcount
#define gcd __gcd
#define n_mod(a, k) ((a % k) + k) % k
#define mod(a, k) (a % k)
#define sz(v) ((int)((v).size()))
#define clr(v, d) memset(v, d, sizeof(v))
#define rep(i, v) for (int i = 0; i < sz(v); ++i)
#define lp(i, n) for (int i = 0; i < (int)(n); ++i)
#define lpi(i, j, n) for (int i = (j); i < (int)(n); ++i)
#define lpd(i, j, n) for (int i = (j); i >= (int)(n); --i)
#define LSOne(S) (S & (-S))
#define repa(v) lpi(i, 0, sz(v)) lpi(j, 0, sz(v[i]))
#define P(x) cout << #x << " = { " << x << " }\n"
#define PB push_back
#define MP make_pair
#define M_PI 3.14159265358979323846
#define fast_IO                       \
    ios_base::sync_with_stdio(false); \
    cin.tie(NULL);                    \
    cout.tie(NULL);
#define file_IO                       \
    freopen("input.txt", "r", stdin); \
    freopen("output.txt", "w", stdout)
#define TIME fprintf(stderr, "\nTIME = %lf\n", 1.0 * clock() / CLOCKS_PER_SEC);
typedef long long ll;
typedef long double ld;
typedef vector<int> vi;
typedef vector<double> vd;
typedef vector<vi> vvi;
typedef vector<vd> vvd;
typedef pair<int, int> pii;
typedef vector<pii> vii;
typedef vector<string> vs;
bool used[10001];

int main()
{
#ifndef ONLINE_JUDGE
    file_IO;
#else
    fast_IO;
#endif
    int n, k;
    cin >> n >> k;
    int arr[n];
    int low = 1;
    int MAX = n;

    lp(i, k)
    {
        if (i % 2 == 0)
        {
            used[low] = 1;
            cout << low++ << ' ';
        }
        else
        {
            used[MAX] = 1;
            cout << MAX-- << ' ';
        }
    }
    if (k % 2 != 0)
    {
        for (int i = 0; i < n; ++i)
        {
            if (!used[i + 1])
            {
                cout << i + 1 << ' ';
            }
        }
    }
    else
    {
        for (int i = n - 1; i >= 0; --i)
        {
            if (!used[i + 1])
            {
                cout << i + 1 << ' ';
            }
        }
    }
}


#include <bits/stdc++.h>
using namespace std;
#define all(v) ((v).begin()), ((v).end())
#define s(n) scanf("%d", &n)
#define sc(n) scanf("%c", &n)
#define sl(n) scanf("%lld", &n)
#define sf(n) scanf("%lf", &n)
#define ss(n) scanf("%s", n)
#define INF (int)1e9
#define EPS 1e-9
#define bitcount __builtin_popcount
#define gcd __gcd
#define n_mod(a, k) ((a % k) + k) % k
#define mod(a, k) (a % k)
#define sz(v) ((int)((v).size()))
#define clr(v, d) memset(v, d, sizeof(v))
#define rep(i, v) for (int i = 0; i < sz(v); ++i)
#define lp(i, n) for (int i = 0; i < (int)(n); ++i)
#define lpi(i, j, n) for (int i = (j); i < (int)(n); ++i)
#define lpd(i, j, n) for (int i = (j); i >= (int)(n); --i)
#define LSOne(S) (S & (-S))
#define repa(v) lpi(i, 0, sz(v)) lpi(j, 0, sz(v[i]))
#define P(x) cout << #x << " = { " << x << " }\n"
#define PB push_back
#define MP make_pair
#define M_PI 3.14159265358979323846
#define fast_IO                       \
    ios_base::sync_with_stdio(false); \
    cin.tie(NULL);                    \
    cout.tie(NULL);
#define file_IO                       \
    freopen("input.txt", "r", stdin); \
    freopen("output.txt", "w", stdout)
#define TIME fprintf(stderr, "\nTIME = %lf\n", 1.0 * clock() / CLOCKS_PER_SEC);
typedef long long ll;
typedef long double ld;
typedef vector<int> vi;
typedef vector<double> vd;
typedef vector<vi> vvi;
typedef vector<vd> vvd;
typedef pair<int, int> pii;
typedef vector<pii> vii;
typedef vector<string> vs;
set<int> t;
int main()
{
#ifndef ONLINE_JUDGE
    file_IO;
#else
    fast_IO;
#endif
    int n, k;
    cin >> n >> k;
    int arr[n];
    lp(i, n)
    {
        arr[i] = i + 1;
    }
    do
    {
        t.clear();
        bool sol = false;
        for (int i = 0; i < n - 1; i++)
        {
            t.insert(abs(arr[i] - arr[i + 1]));
            if (t.size() == k)
            {
                lp(i, n)
                {
                    cout << arr[i] << ' ';
                }
                cout << '\n';

                sol = true;
            }
            if (sol)
                break;
        }
        if (sol)
            break;
    } while (next_permutation(arr, arr + n));
}


#include <bits/stdc++.h>
using namespace std;
#define all(v) ((v).begin()), ((v).end())
#define s(n) scanf("%d", &n)
#define sc(n) scanf("%c", &n)
#define sl(n) scanf("%lld", &n)
#define sf(n) scanf("%lf", &n)
#define ss(n) scanf("%s", n)
#define INF (int)1e9
#define EPS 1e-9
#define bitcount __builtin_popcount
#define gcd __gcd
#define n_mod(a, k) ((a % k) + k) % k
#define mod(a, k) (a % k)
#define sz(v) ((int)((v).size()))
#define clr(v, d) memset(v, d, sizeof(v))
#define rep(i, v) for (int i = 0; i < sz(v); ++i)
#define lp(i, n) for (int i = 0; i < (int)(n); ++i)
#define lpi(i, j, n) for (int i = (j); i < (int)(n); ++i)
#define lpd(i, j, n) for (int i = (j); i >= (int)(n); --i)
#define LSOne(S) (S & (-S))
#define repa(v) lpi(i, 0, sz(v)) lpi(j, 0, sz(v[i]))
#define P(x) cout << #x << " = { " << x << " }\n"
#define PB push_back
#define MP make_pair
#define M_PI 3.14159265358979323846
#define fast_IO                       \
    ios_base::sync_with_stdio(false); \
    cin.tie(NULL);                    \
    cout.tie(NULL);
#define file_IO                       \
    freopen("input.txt", "r", stdin); \
    freopen("output.txt", "w", stdout)
#define TIME fprintf(stderr, "\nTIME = %lf\n", 1.0 * clock() / CLOCKS_PER_SEC);
typedef long long ll;
typedef long double ld;
typedef vector<int> vi;
typedef vector<double> vd;
typedef vector<vi> vvi;
typedef vector<vd> vvd;
typedef pair<int, int> pii;
typedef vector<pii> vii;
typedef vector<string> vs;
const int MAX = 1e5 + 10;
bool used[MAX];

int main()
{
#ifndef ONLINE_JUDGE
    file_IO;
#else
    fast_IO;
#endif
    int n, k;
    cin >> n >> k;
    int arr[n];
    int low = 1;
    int MAX = n;

    lp(i, k)
    {
        if (i % 2 == 0)
        {
            used[low] = 1;
            cout << low++ << ' ';
        }
        else
        {
            used[MAX] = 1;
            cout << MAX-- << ' ';
        }
    }
    if (k % 2 != 0)
    {
        for (int i = 0; i < n; ++i)
        {
            if (!used[i + 1])
            {
                cout << i + 1 << ' ';
            }
        }
    }
    else
    {
        for (int i = n - 1; i >= 0; --i)
        {
            if (!used[i + 1])
            {
                cout << i + 1 << ' ';
            }
        }
    }
}


#include<bits/stdc++.h>
using namespace std;
int n, k;

int main(){
  cin >> n >> k;
  int ks = k+1;
  int i = 1, x = 1;
  while(i <= k+1){
    if(i % 2 == 1){
      cout << x << " ";
      x++;
    }
    else {
      cout << ks << " ";
      ks--;
    }
    i++;
  }
  for(int i = k+2; i <= n; i++)
    cout << i << " ";

  return 0;
}


#include<bits/stdc++.h>
using namespace std;
#define rep(i,a,b) for(int i = a; i <= b; ++i)
#define loop(n) for(int i = 0; i < n; ++i)
#define pb push_back
#define sz(x) (int)(x).size()
#define int long long
#define deb(x) cout << '>' << #x << ": " << x << endl;
#define all(x) (x).begin(),(x).end()
typedef vector<int> vi;
int i = 0,j = 0;

void solve(){
   int n,k;cin >> n >> k;
   cout << n << " ";
   //k - 1 differences;
   int p = 0,i = 1,j = n - 1;
   bool ip = 1;
   while(p < k - 1){
        if(ip){
            cout << i << " ";
            ++i;
            ip = 0;
        }
        else{
            cout << j << " ";
            --j;
            ip = 1;
        }
        ++p;
   }
   if(ip){
        for(int q = j; q >= i; --q)cout << q << " ";
   }
   else{
        for(int q = i; q <= j; ++q)cout << q <<  " ";

    }
}

signed main(){
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    int t = 1;
//    cin>>t;
    while(t--)
        solve();
}


#define _CRT_SECURE_NO_WARNINGS
//           Allah_Almost3aan
//*{ربى.. كنْ لىِ خيرَ مدبر فإنى لا احسنُ التدبير}*
#include<bits/stdc++.h>
#include <unordered_map>
using namespace std;
typedef long long int lli;
typedef  long long ll;
typedef  unsigned long long ull;
typedef  long double ld;
#define ed "\n"
#define INF 1e9
#define SZ 1000007
#define ff first
#define ss second
#define sz(a) a.size()
#define RT(v) return cout<<v<<ed,0
#define stpr(n) fixed<<setprecision(n)
#define all(c) c.begin(), c.end()
#define rall(c) c.rbegin(), c.rend()
string ys = "YES", no = "NO", st;
int di[8] = { 1, 0, -1, 0, -1, 1, -1, 1 };
int dj[8] = { 0, -1, 0, 1, 1, 1, -1, -1 };
const int N = 1.5 * 10000000 + 16;
const lli  OO = 1e18;
lli mod = 1e9 + 7;
void fast() {
	ios::sync_with_stdio(false);
	cin.tie(0); cout.tie(0);
}
int main()
{
	fast();
	int q;	//cin >> q;
	q = 1;
	while (q--)
	{
		int n, k; cin >> n >> k;
		int i = 1, j = n;
		bool ola = true;
		while (n--)
		{
			cout<<(ola? i++:j--)<<" ";
			if (k > 1)
			{
				k--;
				ola = !ola;
			}
		}
	}
}


#include <set>
#include <map>
#include <ctime>
#include <cmath>
#include <cstdio>
#include <cstring>
#include <cstdlib>
#include <iostream>
#include <algorithm>

#define MaxN 200010

using namespace std;

int N, K, P;
int head[MaxN], prep[MaxN], v[MaxN], m0, dep[MaxN], Ans;
long long pre[MaxN];
bool vis[MaxN];

void AddEdge(int a, int b) {
    ++m0; v[m0] = b; prep[m0] = head[a]; head[a] = m0;
}

void Dfs(int now) {
    vis[now] = 1;
    for(int i = head[now]; i; i = prep[i])
        if(!vis[v[i]]) {
            dep[v[i]] = dep[now] + 1;
            Dfs(v[i]);
        }
}

int Max(int a, int b) {
    return a > b ? a : b;
}

int main() {
    int i, j, a, b;
    scanf("%d%d%d", &N, &K, &P);
    for(i = 1; i < N; ++i) {
        scanf("%d%d", &a, &b);
        AddEdge(a, b); AddEdge(b, a);
    }
    if(K == 0) {
        puts("0");
        return 0;
    }
    Dfs(1);
    sort(dep + 1, dep + N + 1);
    int rr = 1;
    for(i = 2; i <= N; ++i) pre[i] = pre[i - 1] + dep[i];
    for(i = 1; i <= N; ++i) {
        while(rr < N && dep[rr + 1] <= i) ++rr;
        long long l = 0, r = rr + 1, mid;
        while(l < r - 1) {
            mid = l + r >> 1;
            long long w = i * mid - pre[mid];
            if(w > P) r = mid;
            else l = mid;
        }
        Ans = Max(Ans, l - 1);
    }
    printf("%d\n", Ans);
    return 0;
}


#include <set>
#include <map>
#include <ctime>
#include <cmath>
#include <cstdio>
#include <cstring>
#include <cstdlib>
#include <iostream>
#include <algorithm>

#define MaxN 200010

using namespace std;

int N, K, P;
int head[MaxN], prep[MaxN], v[MaxN], m0, dep[MaxN], Ans;
long long pre[MaxN];
bool vis[MaxN];

void AddEdge(int a, int b) {
    ++m0; v[m0] = b; prep[m0] = head[a]; head[a] = m0;
}

void Dfs(int now) {
    vis[now] = 1;
    for(int i = head[now]; i; i = prep[i])
        if(!vis[v[i]]) {
            dep[v[i]] = dep[now] + 1;
            Dfs(v[i]);
        }
}

int Max(int a, int b) {
    return a > b ? a : b;
}

int Min(int a, int b) {
    return a < b ? a : b;
}

int main() {
    int i, j, a, b;
    scanf("%d%d%d", &N, &K, &P);
    for(i = 1; i < N; ++i) {
        scanf("%d%d", &a, &b);
        AddEdge(a, b); AddEdge(b, a);
    }
    if(K == 0) {
        puts("0");
        return 0;
    }
    Dfs(1);
    sort(dep + 1, dep + N + 1);
    int rr = 0;
    for(i = 1; i <= N; ++i) dep[i - 1] = dep[i];
    for(i = 1; i < N; ++i) pre[i] = pre[i - 1] + dep[i];
    for(i = 1; i <= N; ++i) {
        while(rr < N - 1 && dep[rr + 1] <= i) ++rr;
        long long l = 0, r = Min(K + 1, rr + 1), mid;
        while(l < r - 1) {
            mid = l + r >> 1;
            long long w = i * mid - pre[mid];
            if(w > P) r = mid;
            else l = mid;
        }
        Ans = Max(Ans, l);
    }
    printf("%d\n", Ans);
    return 0;
}


#include<bits/stdc++.h>
using namespace std;
typedef pair<int,int> PII;
typedef long long ll;
template<class T> T sqr(T x) {return x*x;}
#define pi acos(-1)
#define INF 100000000
#define debug(x) cerr<<#x"="<<x<<"\n";
#define foreach(it,v) for (__typeof((v).begin()) it=(v).begin();it!=(v).end();it++)

ll d[110000],sum[110000];
int v[110000];
vector<int> a[110000];

void dfs(int x,int dep) {
    int i,y;
    d[x]=dep;
    v[x]=1;
    for (i=0;i<a[x].size();i++) {
        y=a[x][i];
        if (!v[y]) dfs(y,dep+1);
    }
}

int main() {
    int n,m,p,x,y,ans,i,l,r,mid;
    scanf("%d%d%d",&n,&m,&p);
    for (i=1;i<n;i++) {
        scanf("%d%d",&x,&y);
        a[x].push_back(y);
        a[y].push_back(x);
    }
    dfs(1,1);
    sort(d+1,d+n+1);
    partial_sum(d,d+n+1,sum);
    ans=0;
    for (i=2;i<=n;i++) {
        l=2;r=i;
        while (l<=r) {
            mid=(l+r)/2;
            if (d[i]*(i-mid+1)-(sum[i]-sum[mid-1])<=p) r=mid-1;
            else l=mid+1;
        }
        ans=max(ans,i-r);
    }
    ans=min(ans,m);
    printf("%d\n",ans);
}


#include<bits/stdc++.h>
using namespace std;
typedef pair<int,int> PII;
typedef long long ll;
template<class T> T sqr(T x) {return x*x;}
#define pi acos(-1)
#define INF 100000000
#define debug(x) cerr<<#x"="<<x<<"\n";
#define foreach(it,v) for (__typeof((v).begin()) it=(v).begin();it!=(v).end();it++)

ll d[110000],sum[110000];
int v[110000];
vector<int> a[110000];

void dfs(int x,int dep) {
    int i,y;
    d[x]=dep;
    v[x]=1;
    for (i=0;i<a[x].size();i++) {
        y=a[x][i];
        if (!v[y]) dfs(y,dep+1);
    }
}

int main() {
    int n,m,p,x,y,ans,i,l,r,mid;
    scanf("%d%d%d",&n,&m,&p);
    for (i=1;i<n;i++) {
        scanf("%d%d",&x,&y);
        a[x].push_back(y);
        a[y].push_back(x);
    }
    dfs(1,1);
    sort(d+1,d+n+1);
    partial_sum(d,d+n+1,sum);
    ans=0;
    for (i=2;i<=n;i++) {
        l=2;r=i;
        while (l<=r) {
            mid=(l+r)/2;
            if (d[mid]*(i-mid+1)-(sum[i]-sum[mid-1])<=p) r=mid-1;
            else l=mid+1;
        }
        ans=max(ans,i-r);
    }
    ans=min(ans,m);
    printf("%d\n",ans);
}


#include<bits/stdc++.h>
using namespace std;
typedef pair<int,int> PII;
typedef long long ll;
template<class T> T sqr(T x) {return x*x;}
#define pi acos(-1)
#define INF 100000000
#define debug(x) cerr<<#x"="<<x<<"\n";
#define foreach(it,v) for (__typeof((v).begin()) it=(v).begin();it!=(v).end();it++)

ll d[110000],sum[110000];
int v[110000];
vector<int> a[110000];

void dfs(int x,int dep) {
    int i,y;
    d[x]=dep;
    v[x]=1;
    for (i=0;i<a[x].size();i++) {
        y=a[x][i];
        if (!v[y]) dfs(y,dep+1);
    }
}

int main() {
    int n,m,p,x,y,ans;
    ll i,l,r,mid;
    scanf("%d%d%d",&n,&m,&p);
    for (i=1;i<m;i++) {
        scanf("%d%d",&x,&y);
        a[x].push_back(y);
        a[y].push_back(x);
    }
    dfs(1,1);
    sort(d+1,d+n+1);
    partial_sum(d,d+n+1,sum);
    ans=0;
    for (i=2;i<=n;i++) {
        l=2;r=i;
        while (l<=r) {
            mid=(l+r)/2;
            if (d[mid]*(i-1)-(sum[i]-sum[mid-1])<=p) r=mid-1;
            else l=mid+1;
        }
        ans=max(ans,int(i-r));
    }
    ans=min(ans,m);
    printf("%d\n",ans);
}


#include<bits/stdc++.h>
using namespace std;
typedef pair<int,int> PII;
typedef long long ll;
template<class T> T sqr(T x) {return x*x;}
#define pi acos(-1)
#define INF 100000000
#define debug(x) cerr<<#x"="<<x<<"\n";
#define foreach(it,v) for (__typeof((v).begin()) it=(v).begin();it!=(v).end();it++)

ll d[110000],sum[110000];
int v[110000];
vector<int> a[110000];

void dfs(int x,int dep) {
    int i,y;
    d[x]=dep;
    v[x]=1;
    for (i=0;i<a[x].size();i++) {
        y=a[x][i];
        if (!v[y]) dfs(y,dep+1);
    }
}

int main() {
    int n,m,p,x,y,ans;
    ll i,l,r,mid;
    scanf("%d%d%d",&n,&m,&p);
    for (i=1;i<m;i++) {
        scanf("%d%d",&x,&y);
        a[x].push_back(y);
        a[y].push_back(x);
    }
    dfs(1,1);
    sort(d+1,d+n+1);
//  partial_sum(d,d+n+1,sum);
    ans=0;
    for (i=2;i<=n;i++) {
        l=2;r=i;
        while (l<=r) {
            mid=(l+r)/2;
            if (d[mid]*(i-1)-(sum[i]-sum[mid-1])<=p) r=mid-1;
            else l=mid+1;
        }
        ans=max(ans,int(i-r));
    }
    ans=min(ans,m);
    printf("%d\n",ans);
}


#include<bits/stdc++.h>
using namespace std;
typedef pair<int,int> PII;
typedef long long ll;
template<class T> T sqr(T x) {return x*x;}
#define pi acos(-1)
#define INF 100000000
#define debug(x) cerr<<#x"="<<x<<"\n";
#define foreach(it,v) for (__typeof((v).begin()) it=(v).begin();it!=(v).end();it++)

ll d[110000],sum[110000];
int v[110000];
vector<int> a[110000];

void dfs(int x,int dep) {
    int i,y;
    d[x]=dep;
    v[x]=1;
    for (i=0;i<a[x].size();i++) {
        y=a[x][i];
        if (!v[y]) dfs(y,dep+1);
    }
}

int main() {
    int n,m,p,x,y,ans,i,l,r,mid;
    scanf("%d%d%d",&n,&m,&p);
    for (i=1;i<n;i++) {
        scanf("%d%d",&x,&y);
        a[x].push_back(y);
        a[y].push_back(x);
    }
    dfs(1,1);
    sort(d+1,d+n+1);
    partial_sum(d,d+n+1,sum);
    ans=0;
    for (i=2;i<=n;i++) {
        l=2;r=i;
        while (l<=r) {
            mid=(l+r)/2;
            if (d[mid]*(i-1)-(sum[i]-sum[mid-1])<=p) r=mid-1;
            else l=mid+1;
        }
        ans=max(ans,i-r);
    }
    ans=min(ans,m);
    printf("%d\n",ans);
}


#include<bits/stdc++.h>
using namespace std;
typedef pair<int,int> PII;
typedef long long ll;
template<class T> T sqr(T x) {return x*x;}
#define pi acos(-1)
#define INF 100000000
#define debug(x) cerr<<#x"="<<x<<"\n";
#define foreach(it,v) for (__typeof((v).begin()) it=(v).begin();it!=(v).end();it++)

ll d[110000],sum[110000];
int v[110000];
vector<int> a[110000];

void dfs(int x,int dep) {
	int i,y;
	d[x]=dep;
	v[x]=1;
	for (i=0;i<a[x].size();i++) {
		y=a[x][i];
		if (!v[y]) dfs(y,dep+1);
	}
}

int main() {
	int n,m,p,x,y,ans;
	ll i,l,r,mid;
	scanf("%d%d%d",&n,&m,&p);
	for (i=1;i<m;i++) {
		scanf("%d%d",&x,&y);
		a[x].push_back(y);
		a[y].push_back(x);
	}
	dfs(1,1);
	sort(d+1,d+n+1);
//	partial_sum(d,d+n+1,sum);
	ans=0;
	for (i=2;i<=n;i++) {
		l=2;r=2;
		while (l<=r) {
			mid=(l+r)/2;
			if (d[mid]*(i-1)-(sum[i]-sum[mid-1])<=p) r=mid-1;
			else l=mid+1;
		}
		ans=max(ans,int(i-r));
	}
	ans=min(ans,m);
	printf("%d\n",ans);
}


#include<bits/stdc++.h>
using namespace std;
typedef pair<int,int> PII;
typedef long long ll;
template<class T> T sqr(T x) {return x*x;}
#define pi acos(-1)
#define INF 100000000
#define debug(x) cerr<<#x"="<<x<<"\n";
#define foreach(it,v) for (__typeof((v).begin()) it=(v).begin();it!=(v).end();it++)

ll d[110000],sum[110000];
int v[110000];
vector<int> a[110000];

void dfs(int x,int dep) {
    int i,y;
    d[x]=dep;
    v[x]=1;
    for (i=0;i<a[x].size();i++) {
        y=a[x][i];
        if (!v[y]) dfs(y,dep+1);
    }
}

int main() {
    int n,m,p,x,y,ans;
    ll i,l,r,mid;
    scanf("%d%d%d",&n,&m,&p);
    for (i=1;i<n;i++) {
        scanf("%d%d",&x,&y);
        a[x].push_back(y);
        a[y].push_back(x);
    }
    dfs(1,1);
    sort(d+1,d+n+1);
    partial_sum(d,d+n+1,sum);
    ans=0;
    for (i=2;i<=n;i++) {
        l=2;r=i;
        while (l<=r) {
            mid=(l+r)/2;
            if (d[mid]*(i-1)-(sum[i]-sum[mid-1])<=p) r=mid-1;
            else l=mid+1;
        }
        ans=max(ans,int(i-r));
    }
    ans=min(ans,m);
    printf("%d\n",ans);
}


#include <cstdio>
#include <cmath>
#include <cstring>
#include <cassert>
#include <cstdlib>
#include <ctime>

#include <algorithm>
#include <iomanip>
#include <iostream>
#include <vector>
#include <set>
#include <queue>
#include <map>

using namespace std;

typedef long long ll;

const int max_n = 1e5 + 10;

vector<vector<int> > g;
int m, k, p;
int ch[max_n];
int hmax;

ll cs[2][max_n];

void dfs(int v, int h, int pr)
{
    hmax = max(hmax, h);
    ++ch[h];
    for (int i = 0; i < (int) g[v].size(); ++i) {
        int u = g[v][i];
        if (u != pr)
            dfs(u, h + 1, v);
    }
}

ll sum2(int l, int r)
{
    ll result = cs[1][r];
    if (l > 0) {
        result -= cs[1][l - 1];
        result -= cs[0][l - 1] * (r - l + 1);
    }
    return result;
}

ll sum1(int l, int r)
{
    ll result = cs[0][r];
    if (l > 0) {
        result -= cs[0][l - 1];
    }
    return result;
}

bool check(int k)
{
    if (k >= m) return false;
    for (int y1 = 1, y2 = 1; y1 <= hmax; ++y1) {
        if (y2 < y1) y2 = y1;
        int c = sum1(y1, y2);
        while (y2 < hmax && c < k) {
            ++y2;
            c = sum1(y1, y2);
        }
        if (c >= k) {
            ll cost = 0;
            if (y2 > y1) {
                cost = sum2(y1, y2 - 1);
            }
            if (cost <= p) return true;
        }
    }
    return false;
}

int main()
{
  //  freopen("input.txt", "r", stdin);
  //  freopen("output.txt", "w", stdout);

    scanf("%d%d%d", &m, &k, &p);
    k = min(k, m - 1);
    g.resize(m);
    for (int i = 0; i < m - 1; ++i) {
        int v1, v2;
        scanf("%d%d", &v1, &v2);
        --v1; --v2;
        g[v1].push_back(v2);
        g[v2].push_back(v1);
    }

    hmax = 0;
    dfs(0, 0, -1);

    cs[0][0] = 1;
    for (int i = 1; i <= hmax; ++i)
        cs[0][i] = ch[i] + cs[0][i - 1];

    cs[1][0] = 1;
    for (int i = 1; i <= hmax; ++i)
        cs[1][i] = cs[0][i] + cs[1][i - 1];

    int bl = 1, br = k, ba = 0;
    while (bl <= br) {
        int bm = (bl + br) >> 1;
        if (check(bm)) {
            ba = bm;
            bl = bm + 1;
        } else {
            br = bm - 1;
        }
    }
    printf("%d\n", ba);

    return 0;
}


#include <cstdio>
#include <cmath>
#include <cstring>
#include <cassert>
#include <cstdlib>
#include <ctime>

#include <algorithm>
#include <iomanip>
#include <iostream>
#include <vector>
#include <set>
#include <queue>
#include <map>

using namespace std;

typedef long long ll;

const int max_n = 1e5 + 10;

vector<vector<int> > g;
int m, k, p;
int ch[max_n];
int hmax;

ll cs[2][max_n];

void dfs(int v, int h, int pr)
{
    hmax = max(hmax, h);
    ++ch[h];
    for (int i = 0; i < (int) g[v].size(); ++i) {
        int u = g[v][i];
        if (u != pr)
            dfs(u, h + 1, v);
    }
}

ll sum2(int l, int r)
{
    ll result = cs[1][r];
    if (l > 0) {
        result -= cs[1][l - 1];
        result -= cs[0][l - 1] * (r - l + 1);
    }
    return result;
}

ll sum1(int l, int r)
{
    ll result = cs[0][r];
    if (l > 0) {
        result -= cs[0][l - 1];
    }
    return result;
}

bool check(int k)
{
    for (int y1 = 1, y2 = 1; y1 <= hmax; ++y1) {
        if (y2 < y1) y2 = y1;
        int c = sum1(y1, y2);
        while (y2 < hmax && c < k) {
            ++y2;
            c = sum1(y1, y2);
        }
        if (c >= k) {
            ll cost = 0;
            if (y2 > y1) {
                cost = sum2(y1, y2 - 1);
            }
            if (cost <= p) return true;
        }
    }
    return false;
}

int main()
{
  //  freopen("input.txt", "r", stdin);
  //  freopen("output.txt", "w", stdout);

    scanf("%d%d%d", &m, &k, &p);
    k = min(k, m - 1);
    g.resize(m);
    for (int i = 0; i < m - 1; ++i) {
        int v1, v2;
        scanf("%d%d", &v1, &v2);
        --v1; --v2;
        g[v1].push_back(v2);
        g[v2].push_back(v1);
    }

    hmax = 0;
    dfs(0, 0, -1);

    cs[0][0] = 1;
    for (int i = 1; i <= hmax; ++i)
        cs[0][i] = ch[i] + cs[0][i - 1];

    cs[1][0] = 1;
    for (int i = 1; i <= hmax; ++i)
        cs[1][i] = cs[0][i] + cs[1][i - 1];

    int bl = 1, br = k, ba = 0;
    while (bl <= br) {
        int bm = (bl + br) >> 1;
        if (check(bm)) {
            ba = bm;
            bl = bm + 1;
        } else {
            br = bm - 1;
        }
    }
    printf("%d\n", ba);

    return 0;
}


#include <cstdio>
#include <cmath>
#include <cstring>
#include <cassert>
#include <cstdlib>
#include <ctime>

#include <algorithm>
#include <iomanip>
#include <iostream>
#include <vector>
#include <set>
#include <queue>
#include <map>

using namespace std;

typedef long long ll;

const int max_n = 1e5 + 10;

vector<vector<int> > g;
int m, k, p;
int ch[max_n];
int hmax;

ll cs[2][max_n];

void dfs(int v, int h, int pr)
{
    hmax = max(hmax, h);
    ++ch[h];
    for (int i = 0; i < (int) g[v].size(); ++i) {
        int u = g[v][i];
        if (u != pr)
            dfs(u, h + 1, v);
    }
}

ll sum2(int l, int r)
{
    ll result = cs[1][r];
    if (l > 0) {
        result -= cs[1][l - 1];
        result -= cs[0][l - 1] * (r - l + 1);
    }
    return result;
}

ll sum1(int l, int r)
{
    ll result = cs[0][r];
    if (l > 0) {
        result -= cs[0][l - 1];
    }
    return result;
}

bool check(int k)
{
    for (int y1 = 1, y2 = 1; y1 <= hmax; ++y1) {
        if (y2 < y1) y2 = y1;
        int c = sum1(y1, y2);
        while (y2 < hmax && c < k) {
            ++y2;
            c = sum1(y1, y2);
        }
        if (c >= k) {
            ll cost = 0;
            if (y2 > y1) {
                cost = sum2(y1, y2 - 1);
            }
            if (cost <= p) return true;
        }
    }
    return false;
}

int main()
{
  //  freopen("input.txt", "r", stdin);
  //  freopen("output.txt", "w", stdout);

    scanf("%d%d%d", &m, &k, &p);
    k = min(k, m);
    g.resize(m);
    for (int i = 0; i < m - 1; ++i) {
        int v1, v2;
        scanf("%d%d", &v1, &v2);
        --v1; --v2;
        g[v1].push_back(v2);
        g[v2].push_back(v1);
    }

    hmax = 0;
    dfs(0, 0, -1);

    cs[0][0] = 1;
    for (int i = 1; i <= hmax; ++i)
        cs[0][i] = ch[i] + cs[0][i - 1];

    cs[1][0] = 1;
    for (int i = 1; i <= hmax; ++i)
        cs[1][i] = cs[0][i] + cs[1][i - 1];

    int bl = 1, br = k, ba = 0;
    while (bl <= br) {
        int bm = (bl + br) >> 1;
        if (check(bm)) {
            ba = bm;
            bl = bm + 1;
        } else {
            br = bm - 1;
        }
    }
    printf("%d\n", ba);

    return 0;
}


#include <cstdio>
#include <cmath>
#include <cstring>
#include <cassert>
#include <cstdlib>
#include <ctime>

#include <algorithm>
#include <iomanip>
#include <iostream>
#include <vector>
#include <set>
#include <queue>
#include <map>

using namespace std;

typedef long long ll;

const int max_n = 1e5 + 10;

vector<vector<int> > g;
int m, k, p;
int ch[max_n];
int hmax;

ll cs[2][max_n];

void dfs(int v, int h, int pr)
{
    hmax = max(hmax, h);
    ++ch[h];
    for (int i = 0; i < (int) g[v].size(); ++i) {
        int u = g[v][i];
        if (u != pr)
            dfs(u, h + 1, v);
    }
}

ll sum2(int l, int r)
{
    ll result = cs[1][r];
    if (l > 0) {
        result -= cs[1][l - 1];
        result -= cs[0][l - 1] * (r - l + 1);
    }
    return result;
}

ll sum1(int l, int r)
{
    ll result = cs[0][r];
    if (l > 0) {
        result -= cs[0][l - 1];
    }
    return result;
}

bool check(int k)
{
    if (k >= m) return false;
    for (int y1 = hmax, y2 = hmax; y2 > 0; --y2) {
        if (y1 > y2) y1 = y2;
        ll c = sum1(y1, y2);
        while (y1 > 1 && c < k) {
            --y1;
            c = sum1(y1, y2);
        }
        if (c >= k) {
            if (y1 == y2) {
                return true;
            }
            c -= sum1(y1 + 1, y2);
            ll cost = sum2(y1, y2 - 1) - (ch[y1] - c) * (y2 - y1 + 1);
            if (cost <= p) return true;
        }
    }
    return false;
}

int main()
{
  //  freopen("input.txt", "r", stdin);
  //  freopen("output.txt", "w", stdout);

    scanf("%d%d%d", &m, &k, &p);
    k = min(k, m - 1);
    g.resize(m);
    for (int i = 0; i < m - 1; ++i) {
        int v1, v2;
        scanf("%d%d", &v1, &v2);
        --v1; --v2;
        g[v1].push_back(v2);
        g[v2].push_back(v1);
    }

    hmax = 0;
    dfs(0, 0, -1);

    cs[0][0] = 1;
    for (int i = 1; i <= hmax; ++i)
        cs[0][i] = ch[i] + cs[0][i - 1];

    cs[1][0] = 1;
    for (int i = 1; i <= hmax; ++i)
        cs[1][i] = cs[0][i] + cs[1][i - 1];

    int bl = 1, br = k, ba = 0;
    while (bl <= br) {
        int bm = (bl + br) >> 1;
        if (check(bm)) {
            ba = bm;
            bl = bm + 1;
        } else {
            br = bm - 1;
        }
    }
    printf("%d\n", ba);

    return 0;
}


#include <cstdio>
#include <cmath>
#include <cstring>
#include <cassert>
#include <cstdlib>
#include <ctime>

#include <algorithm>
#include <iomanip>
#include <iostream>
#include <vector>
#include <set>
#include <queue>
#include <map>

using namespace std;

typedef long long ll;

const int max_n = 1e5 + 10;

vector<vector<int> > g;
int m, k, p;
int ch[max_n];
int hmax;

ll cs[2][max_n];

void dfs(int v, int h)
{
    hmax = max(hmax, h);
    ++ch[h];
    for (int i = 0; i < (int) g[v].size(); ++i) {
        int u = g[v][i];
        dfs(u, h + 1);
    }
}

ll sum2(int l, int r)
{
    ll result = cs[1][r];
    if (l > 0) {
        result -= cs[1][l - 1];
        result -= cs[0][l - 1] * (r - l + 1);
    }
    return result;
}

ll sum1(int l, int r)
{
    ll result = cs[0][r];
    if (l > 0) {
        result -= cs[0][l - 1];
    }
    return result;
}

bool check(int k)
{
    for (int y1 = 1, y2 = 1; y1 <= hmax; ++y1) {
        if (y2 < y1) y2 = y1;
        int c = sum1(y1, y2);
        while (y2 < hmax && c < k) {
            ++y2;
            c = sum1(y1, y2);
        }
        if (c >= k) {
            ll cost = 0;
            if (y2 > y1) {
                cost = sum2(y1, y2 - 1);
            }
            if (cost <= p) return true;
        }
    }
    return false;
}

int main()
{
  //  freopen("input.txt", "r", stdin);
   // freopen("output.txt", "w", stdout);

    scanf("%d%d%d", &m, &k, &p);
    k = min(k, m);
    g.resize(m);
    for (int i = 0; i < m - 1; ++i) {
        int v1, v2;
        scanf("%d%d", &v1, &v2);
        --v1; --v2;
        if (v2 < v1) swap(v1, v2);
        g[v1].push_back(v2);
    }

    hmax = 0;
    dfs(0, 0);

    cs[0][0] = 1;
    for (int i = 1; i <= hmax; ++i)
        cs[0][i] = ch[i] + cs[0][i - 1];

    cs[1][0] = 1;
    for (int i = 1; i <= hmax; ++i)
        cs[1][i] = cs[0][i] + cs[1][i - 1];

    int bl = 1, br = k, ba = 0;
    while (bl <= br) {
        int bm = (bl + br) >> 1;
        if (check(bm)) {
            ba = bm;
            bl = bm + 1;
        } else {
            br = bm - 1;
        }
    }
    printf("%d\n", ba);

    return 0;
}


#include <cstdio>
#include <cmath>
#include <cstring>
#include <cassert>
#include <cstdlib>
#include <ctime>

#include <algorithm>
#include <iomanip>
#include <iostream>
#include <vector>
#include <set>
#include <queue>
#include <map>

using namespace std;

typedef long long ll;

const int max_n = 1e5 + 10;

vector<vector<int> > g;
int m, k, p;
int ch[max_n];
int hmax;

ll cs[2][max_n];

void dfs(int v, int h, int pr)
{
    hmax = max(hmax, h);
    ++ch[h];
    for (int i = 0; i < (int) g[v].size(); ++i) {
        int u = g[v][i];
        if (u != pr)
            dfs(u, h + 1, v);
    }
}

ll sum2(int l, int r)
{
    ll result = cs[1][r];
    if (l > 0) {
        result -= cs[1][l - 1];
        result -= cs[0][l - 1] * (r - l + 1);
    }
    return result;
}

ll sum1(int l, int r)
{
    ll result = cs[0][r];
    if (l > 0) {
        result -= cs[0][l - 1];
    }
    return result;
}

bool check(int k)
{
    if (k >= m) return false;
    for (int y1 = hmax, y2 = hmax; y2 > 0; --y2) {
        if (y1 > y2) y1 = y2;
        ll c = sum1(y1, y2);
        while (y1 > 1 && c < k) {
            --y1;
            c = sum1(y1, y2);
        }
        if (c >= k) {
            if (y1 == y2) {
                return true;
            }
            c = k - sum1(y1 + 1, y2);
            ll cost = sum2(y1, y2 - 1) - 1LL * (ch[y1] - c) * (y2 - y1);
            if (cost <= p) return true;
        }
    }
    return false;
}

int main()
{
  //  freopen("input.txt", "r", stdin);
   // freopen("output.txt", "w", stdout);

    scanf("%d%d%d", &m, &k, &p);
    k = min(k, m - 1);
    g.resize(m);
    for (int i = 0; i < m - 1; ++i) {
        int v1, v2;
        scanf("%d%d", &v1, &v2);
        --v1; --v2;
        g[v1].push_back(v2);
        g[v2].push_back(v1);
    }

    hmax = 0;
    dfs(0, 0, -1);

    cs[0][0] = 1;
    for (int i = 1; i <= hmax; ++i)
        cs[0][i] = ch[i] + cs[0][i - 1];

    cs[1][0] = 1;
    for (int i = 1; i <= hmax; ++i)
        cs[1][i] = cs[0][i] + cs[1][i - 1];

    int bl = 1, br = k, ba = 0;
    while (bl <= br) {
        int bm = (bl + br) >> 1;
        if (check(bm)) {
            ba = bm;
            bl = bm + 1;
        } else {
            br = bm - 1;
        }
    }
    printf("%d\n", ba);

    return 0;
}


#include <cstdio>
#include <cmath>
#include <cstring>
#include <cassert>
#include <cstdlib>
#include <ctime>

#include <algorithm>
#include <iomanip>
#include <iostream>
#include <vector>
#include <set>
#include <queue>
#include <map>

using namespace std;

typedef long long ll;

const int max_n = 1e5 + 10;

vector<vector<int> > g;
int m, k, p;
int ch[max_n];
int hmax;

ll cs[2][max_n];

void dfs(int v, int h, int pr)
{
    hmax = max(hmax, h);
    ++ch[h];
    for (int i = 0; i < (int) g[v].size(); ++i) {
        int u = g[v][i];
        if (u != pr)
            dfs(u, h + 1, v);
    }
}

ll sum2(int l, int r)
{
    ll result = cs[1][r];
    if (l > 0) {
        result -= cs[1][l - 1];
        result -= cs[0][l - 1] * (r - l + 1);
    }
    return result;
}

ll sum1(int l, int r)
{
    ll result = cs[0][r];
    if (l > 0) {
        result -= cs[0][l - 1];
    }
    return result;
}

bool check(int k)
{
    if (k >= m) return false;
    for (int y1 = hmax, y2 = hmax; y2 > 0; --y2) {
        if (y1 > y2) y1 = y2;
        ll c = sum1(y1, y2);
        while (y1 > 1 && c < k) {
            --y1;
            c = sum1(y1, y2);
        }
        if (c >= k) {
            if (y1 == y2) {
                return true;
            }
            c -= sum1(y1 + 1, y2);
            ll cost = sum2(y1, y2 - 1) - 1LL * (ch[y1] - c) * (y2 - y1);
            if (cost <= p) return true;
        }
    }
    return false;
}

int main()
{
  //  freopen("input.txt", "r", stdin);
  //  freopen("output.txt", "w", stdout);

    scanf("%d%d%d", &m, &k, &p);
    k = min(k, m - 1);
    g.resize(m);
    for (int i = 0; i < m - 1; ++i) {
        int v1, v2;
        scanf("%d%d", &v1, &v2);
        --v1; --v2;
        g[v1].push_back(v2);
        g[v2].push_back(v1);
    }

    hmax = 0;
    dfs(0, 0, -1);

    cs[0][0] = 1;
    for (int i = 1; i <= hmax; ++i)
        cs[0][i] = ch[i] + cs[0][i - 1];

    cs[1][0] = 1;
    for (int i = 1; i <= hmax; ++i)
        cs[1][i] = cs[0][i] + cs[1][i - 1];

    int bl = 1, br = k, ba = 0;
    while (bl <= br) {
        int bm = (bl + br) >> 1;
        if (check(bm)) {
            ba = bm;
            bl = bm + 1;
        } else {
            br = bm - 1;
        }
    }
    printf("%d\n", ba);

    return 0;
}


#include <cstdio>
#include <cmath>
#include <cstring>
#include <cassert>
#include <cstdlib>
#include <ctime>

#include <algorithm>
#include <iomanip>
#include <iostream>
#include <vector>
#include <set>
#include <queue>
#include <map>

using namespace std;

typedef long long ll;

const int max_n = 1e5 + 10;

vector<vector<int> > g;
int m, k, p;
int ch[max_n];
int hmax;

ll cs[2][max_n];

void dfs(int v, int h, int pr)
{
    hmax = max(hmax, h);
    ++ch[h];
    for (int i = 0; i < (int) g[v].size(); ++i) {
        int u = g[v][i];
        if (u != pr)
            dfs(u, h + 1, v);
    }
}

ll sum2(int l, int r)
{
    ll result = cs[1][r];
    if (l > 0) {
        result -= cs[1][l - 1];
        result -= cs[0][l - 1] * (r - l + 1);
    }
    return result;
}

ll sum1(int l, int r)
{
    ll result = cs[0][r];
    if (l > 0) {
        result -= cs[0][l - 1];
    }
    return result;
}

bool check(int k)
{
    if (k >= m) return false;
    for (int y2 = 1; y2 <= hmax; ++y2) {
        int bl = 1, br = y2, ba = -1;
        while (bl <= br) {
            int bm = (bl + br) >> 1;
            if (sum1(bm, y2) >= k) {
                ba = bm;
                bl = bm + 1;
            } else {
                br = bm - 1;
            }
        }
        if (ba == -1) continue;
        int y1 = ba;
        if (y1 == y2) return true;
        int c = k - sum1(y1 + 1, y2);
        ll cost = sum2(y1, y2 - 1) - (ch[y1] - c) * (y2 - y1);
        if (cost <= p) return true;
    }
    return false;
}

int main()
{
  //  freopen("input.txt", "r", stdin);
   // freopen("output.txt", "w", stdout);

    scanf("%d%d%d", &m, &k, &p);
    k = min(k, m - 1);
    g.resize(m);
    for (int i = 0; i < m - 1; ++i) {
        int v1, v2;
        scanf("%d%d", &v1, &v2);
        --v1; --v2;
        g[v1].push_back(v2);
        g[v2].push_back(v1);
    }

    hmax = 0;
    dfs(0, 0, -1);

    cs[0][0] = 1;
    for (int i = 1; i <= hmax; ++i)
        cs[0][i] = ch[i] + cs[0][i - 1];

    cs[1][0] = 1;
    for (int i = 1; i <= hmax; ++i)
        cs[1][i] = cs[0][i] + cs[1][i - 1];

    int bl = 1, br = k, ba = 0;
    while (bl <= br) {
        int bm = (bl + br) >> 1;
        if (check(bm)) {
            ba = bm;
            bl = bm + 1;
        } else {
            br = bm - 1;
        }
    }
    printf("%d\n", ba);

    return 0;
}


#include<iostream>
#include<cmath>
#include<algorithm>
#include<string>
#include<string.h>
#include<vector>
#include<set>
#include<map>
#include<cstdio>
#include<queue>
#include<sstream>
#include<list>
#include<bitset>
#include<ctime>
using namespace std;

typedef long long Int;
#define FOR(i,a,b) for(Int i=(a); i<=(b);++i)
#define mp make_pair
#define pb push_back
#define sz(s) (int)((s).size())
const int inf = 1000000000;
const int MOD = 1000000007;
const double pi=acos(-1.0);

const int N = 100009;
vector<int> g[N+1];
int k[N+1];

void dfs(int v, int h, int fath) {
	k[h]++;
	FOR(i,0,sz(g[v])-1) {
		int to = g[v][i];
		if(to==fath) continue;
		dfs(to, h+1, v);
	}
}

int main() {
	//freopen("input.txt","r",stdin);freopen("output.txt","w",stdout);
	int n,up,p;
	cin>>n>>up>>p;
	up=min(up, n-1);
	FOR(i,1,n-1) {
		int x,y;
		cin>>x>>y;
		g[x].pb(y);
		g[y].pb(x);
	}
	dfs(1, 0, -1);
	Int ans=k[1];
	int last=1;
	Int s=k[1];
	Int fee=0;
	FOR(t,2,n) if(k[t]) {
		fee+=s;
		s+=k[t];
		while(fee>p) {
			s-=k[last];
			fee-=k[last]*(t-last);
			last++;
		}
		Int cur = s;
		if(last>1) cur+=min(k[last-1]+0LL, (p-fee)/(t-last+1));
		ans=max(ans, cur);
	}
	ans=min(ans,up+0LL);
	cout<<ans<<endl;
}


#include <cstdio>
#include <cstring>
#include <cstdlib>
#include <algorithm>
#include <vector>

using namespace std;

const int MAXN = 101000;
vector<int> e[MAXN];
int deep[MAXN],cntd[MAXN];

void dfs(int u,int fath)
{
  deep[u] = deep[fath] + 1;
  ++cntd[deep[u]];

  for(int &v : e[u])
    if (v != fath)
    {
      dfs(v,u);
    }
}

int main()
{
  int n,m,p;
  scanf("%d%d%d",&n,&m,&p);

  for(int i = 0; i < n-1; i++)
    {
      int u,v;
      scanf("%d%d",&u,&v);
      e[u].push_back(v);
      e[v].push_back(u);
    }

  fill(cntd,cntd + n,0);
  deep[0] = -1;
  dfs(1,0);

  int cntNode = 0,cost = 0,maxv = 0;
  for(int l = 1,r = 1; r < n; r++)//Ignore Deep = 0
    {
      cost += cntNode;//Calc new cost
      cntNode += cntd[r];
      while(cost > p)//maintain
	{
	  for(; cntd[l] == 0; ++l);
	  --cntd[l],--cntNode;
	  cost -= r - l;
	}

      maxv = max(cntNode,maxv);
    }

  printf("%d\n",min(maxv,m));
  return 0;
}


import java.io.BufferedReader;
import java.util.Comparator;
import java.io.OutputStream;
import java.io.PrintWriter;
import java.util.Collection;
import java.util.List;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.Arrays;
import java.util.ArrayList;
import java.util.StringTokenizer;
import java.math.BigInteger;
import java.util.Collections;
import java.io.InputStream;

/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 * @author AlexFetisov
 */
public class Main {
	public static void main(String[] args) {
		InputStream inputStream = System.in;
		OutputStream outputStream = System.out;
		InputReader in = new InputReader(inputStream);
		PrintWriter out = new PrintWriter(outputStream);
		TaskD_CF_240 solver = new TaskD_CF_240();
		solver.solve(1, in, out);
		out.close();
	}
}

class TaskD_CF_240 {

    private int[] partSum;
    private int[] inLevel;
    private int money;

    public void solve(int testNumber, InputReader in, PrintWriter out) {
        int n = in.nextInt();
        int maxToFill = Math.min(in.nextInt(), n-1);
        money = in.nextInt();
        Graph g = new Graph();
        g.initGraph(n, n-1);
        for (int i = 0; i < n-1; ++i) {
            int a = in.nextInt() - 1;
            int b = in.nextInt() - 1;
            g.addEdge(a, b);
        }

        // Fill level counter
        int[] levelOfVertex = Parent.getVertexLevels(g, 0, Parent.run(g, 0));
        int maxLevels = ArrayUtils.getMax(levelOfVertex);
        inLevel = new int[maxLevels];
        for (int i = 1; i < n; ++i) {
            ++inLevel[levelOfVertex[i]-1];
        }

//        int maxLevels = in.nextInt();
//        inLevel = new int[maxLevels];
//        for (int i = 0; i < maxLevels; ++i) {
//            inLevel[i] = in.nextInt();
//        }

        // Part sum
        partSum = new int[maxLevels];
        partSum[0] = inLevel[0];
        for (int i = 1; i < maxLevels; ++i) {
            partSum[i] = partSum[i-1] + inLevel[i];
        }

        int left = 1, right = maxToFill, middle, res = 0;
        while (left <= right) {
            middle = (left + right) / 2;
            if (canFill(middle, maxLevels)) {
                res = middle;
                left = middle + 1;
            } else {
                right = middle - 1;
            }
        }

//        left = 1;
//        right = maxToFill;
//        int otherRes = 0;
//        while (left <= right) {
//            middle = (left + right) / 2;
//            if (stupidCanFill(middle, maxLevels)) {
//                otherRes = middle;
//                left = middle + 1;
//            } else {
//                right = middle - 1;
//            }
//        }
//        if (res != otherRes) {
//            throw new AssertionError("RES != STUPID: " + res + " " + otherRes);
//        }
        out.println(res);
    }

    private boolean canFill(int water, int n) {
        int left = 0;
        int right = 0;
        int curWater = inLevel[0];
        if (curWater >= water) {
            return true;
        }

        long wait = 0;
        ++right;
        curWater += inLevel[right];
        while (right + 1 < n && curWater < water) {
            ++right;
            curWater += inLevel[right];
        }

        if (curWater < water) return false;

        while (curWater - inLevel[left] >= water) {
            curWater -= inLevel[left];
            ++left;
        }
        int[] waterOnLevel = new int[n];

        int need = water;
        for (int i = right; need > 0 && i >= left; --i) {
            waterOnLevel[i] = Math.min(inLevel[i], need);
            need -= waterOnLevel[i];
        }
        if (need > 0) return false;

        for (int i = right-1, mult = 1; i >= left; --i, ++mult) {
            wait += waterOnLevel[i] * 1L * mult;
        }
        int curLen = right - left + 1;

        if (wait <= money) return true;

        // move pointer
        ++right;
        for (; right < n; ++right) {
            int add = inLevel[right];
            if (water <= add) return true;
            while (waterOnLevel[left] <= add) {
                wait -= waterOnLevel[left] * 1L * (curLen-1);
                add -= waterOnLevel[left];
                ++left;
                --curLen;
            }
            wait -= waterOnLevel[left] * 1L * (curLen - 1);
            waterOnLevel[left] -= add;
            wait += waterOnLevel[left] * 1L * (curLen);
            ++curLen;
            wait += getSum(partSum, left + 1, right-1);
            waterOnLevel[right] = inLevel[right];

            if (wait <= money) return true;
        }

        return false;
    }

    private long getSum(int[] sum, int from, int to) {
        if (from == 0) return sum[to];
        return sum[to] - sum[from-1];
    }
}

class InputReader {
    private BufferedReader reader;
    private StringTokenizer stt;

    public InputReader(InputStream stream) {
        reader = new BufferedReader(new InputStreamReader(stream));
    }

    public String nextLine() {
        try {
            return reader.readLine();
        } catch (IOException e) {
            return null;
        }
    }

    public String nextString() {
        while (stt == null || !stt.hasMoreTokens()) {
            stt = new StringTokenizer(nextLine());
        }
        return stt.nextToken();
    }

    public int nextInt() {
        return Integer.parseInt(nextString());
    }

}

class Graph {
    public int[] from;
    public int[] to;
    public int[] first;
    public int[] next;
    public int nVertex;
    public int nEdges;
    public int curEdge;

    public Graph() {}

    public void initGraph(int n, int m) {
        curEdge = 0;
        nVertex = n;
        nEdges = m;
        from = new int[m * 2];
        to = new int[m * 2];
        first = new int[n];
        next = new int[m * 2];
        Arrays.fill(first, -1);
    }

    public void addEdge(int a, int b) {
        next[curEdge] = first[a];
        first[a] = curEdge;
        to[curEdge] = b;
        from[curEdge] = a;
        ++curEdge;

        next[curEdge] = first[b];
        first[b] = curEdge;
        to[curEdge] = a;
        from[curEdge] = b;
        ++curEdge;
    }

}

class Parent {
    public static int[] run(Graph tree, int root) {
        int[] parent = new int[tree.nVertex];
        int[] queue = new int[tree.nVertex];
        int front = 0, back = 0;
        queue[back++] = root;
        parent[root] = -1;
        while (front < back) {
            int v = queue[front++];
            for (int i = tree.first[v]; i != -1; i = tree.next[i]) {
                if (parent[v] != tree.to[i]) {
                    queue[back++] = tree.to[i];
                    parent[tree.to[i]] = v;
                }
            }
        }
        return parent;
    }

    public static int[] getVertexLevels(Graph tree, int root, int[] parent) {
        int[] queue = new int[tree.nVertex];
        int front = 0, back = 0;
        queue[back++] = root;
        parent[root] = -1;
        int[] level = new int[tree.nVertex];
        level[root] = 0;
        while (front < back) {
            int v = queue[front++];
            for (int i = tree.first[v]; i != -1; i = tree.next[i]) {
                if (parent[v] != tree.to[i]) {
                    queue[back++] = tree.to[i];
                    level[tree.to[i]] = level[v] + 1;
                }
            }
        }
        return level;
    }
}

class ArrayUtils {

    public static int getMax(int[] a) {
        int result = a[0];
        for (int x : a) result = Math.max(result, x);
        return result;
    }

}


import java.io.BufferedReader;
import java.util.Comparator;
import java.io.OutputStream;
import java.io.PrintWriter;
import java.util.Collection;
import java.util.List;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.Arrays;
import java.util.ArrayList;
import java.util.StringTokenizer;
import java.math.BigInteger;
import java.util.Collections;
import java.io.InputStream;

/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 * @author AlexFetisov
 */
public class Main {
	public static void main(String[] args) {
		InputStream inputStream = System.in;
		OutputStream outputStream = System.out;
		InputReader in = new InputReader(inputStream);
		PrintWriter out = new PrintWriter(outputStream);
		TaskD_CF_240 solver = new TaskD_CF_240();
		solver.solve(1, in, out);
		out.close();
	}
}

class TaskD_CF_240 {

    private int[] partSum;
    private int[] inLevel;
    private int money;

    public void solve(int testNumber, InputReader in, PrintWriter out) {
        int n = in.nextInt();
        int maxToFill = Math.min(in.nextInt(), n);
        money = in.nextInt();
        Graph g = new Graph();
        g.initGraph(n, n-1);
        for (int i = 0; i < n-1; ++i) {
            int a = in.nextInt() - 1;
            int b = in.nextInt() - 1;
            g.addEdge(a, b);
        }

        // Fill level counter
        int[] levelOfVertex = Parent.getVertexLevels(g, 0, Parent.run(g, 0));
        int maxLevels = ArrayUtils.getMax(levelOfVertex);
        inLevel = new int[maxLevels];
        for (int i = 1; i < n; ++i) {
            ++inLevel[levelOfVertex[i]-1];
        }

        // Part sum
        partSum = new int[maxLevels];
        partSum[0] = inLevel[0];
        for (int i = 1; i < maxLevels; ++i) {
            partSum[i] = partSum[i-1] + inLevel[i];
        }

        int left = 1, right = maxToFill, middle, res = 0;
        while (left <= right) {
            middle = (left + right) / 2;

            if (canFill(middle, maxLevels)) {
                res = middle;
                left = middle + 1;
            } else {
                right = middle - 1;
            }
        }
        out.println(res);
    }

    private boolean canFill(int water, int n) {
        int left = 0;
        int right = 0;
        int curWater = inLevel[0];
        if (curWater >= water) {
            return true;
        }

        long wait = 0;
        ++right;
        curWater += inLevel[right];
        while (right + 1 < n && curWater < water) {
            ++right;
            curWater += inLevel[right];
        }

        if (curWater < water) return false;

        while (curWater - inLevel[left] >= water) {
            ++left;
        }
        int[] waterOnLevel = new int[n];

        int need = water;
        for (int i = right; need > 0 && i >= left; --i) {
            waterOnLevel[i] = Math.min(inLevel[i], need);
            need -= waterOnLevel[i];
        }
        if (need > 0) return false;

        for (int i = right-1, mult = 1; need > 0 && i >= left; --i, ++mult) {
            wait += waterOnLevel[i] * 1L * mult;
        }
        int curLen = right - left + 1;

        if (wait <= money) return true;

        // move pointer
        ++right;
        for (; right < n; ++right) {
            int add = inLevel[right];
            if (water <= add) return true;
            while (waterOnLevel[left] <= add) {
                wait -= waterOnLevel[left] * 1L * (curLen-1);
                ++left;
                add -= waterOnLevel[left];
                --curLen;
            }
            wait -= waterOnLevel[left] * 1L * (curLen - 1);
            waterOnLevel[left] -= add;
            wait += waterOnLevel[left] * 1L * (curLen);
            ++curLen;
            wait += getSum(partSum, left + 1, right-1);
            waterOnLevel[right] = inLevel[right];

            if (wait <= money) return true;
        }

        return false;
    }

    private long getSum(int[] sum, int from, int to) {
        if (from == 0) return sum[to];
        return sum[to] - sum[from-1];
    }
}

class InputReader {
    private BufferedReader reader;
    private StringTokenizer stt;

    public InputReader(InputStream stream) {
        reader = new BufferedReader(new InputStreamReader(stream));
    }

    public String nextLine() {
        try {
            return reader.readLine();
        } catch (IOException e) {
            return null;
        }
    }

    public String nextString() {
        while (stt == null || !stt.hasMoreTokens()) {
            stt = new StringTokenizer(nextLine());
        }
        return stt.nextToken();
    }

    public int nextInt() {
        return Integer.parseInt(nextString());
    }

}

class Graph {
    public int[] from;
    public int[] to;
    public int[] first;
    public int[] next;
    public int nVertex;
    public int nEdges;
    public int curEdge;

    public Graph() {}

    public void initGraph(int n, int m) {
        curEdge = 0;
        nVertex = n;
        nEdges = m;
        from = new int[m * 2];
        to = new int[m * 2];
        first = new int[n];
        next = new int[m * 2];
        Arrays.fill(first, -1);
    }

    public void addEdge(int a, int b) {
        next[curEdge] = first[a];
        first[a] = curEdge;
        to[curEdge] = b;
        from[curEdge] = a;
        ++curEdge;

        next[curEdge] = first[b];
        first[b] = curEdge;
        to[curEdge] = a;
        from[curEdge] = b;
        ++curEdge;
    }

}

class Parent {
    public static int[] run(Graph tree, int root) {
        int[] parent = new int[tree.nVertex];
        int[] queue = new int[tree.nVertex];
        int front = 0, back = 0;
        queue[back++] = root;
        parent[root] = -1;
        while (front < back) {
            int v = queue[front++];
            for (int i = tree.first[v]; i != -1; i = tree.next[i]) {
                if (parent[v] != tree.to[i]) {
                    queue[back++] = tree.to[i];
                    parent[tree.to[i]] = v;
                }
            }
        }
        return parent;
    }

    public static int[] getVertexLevels(Graph tree, int root, int[] parent) {
        int[] queue = new int[tree.nVertex];
        int front = 0, back = 0;
        queue[back++] = root;
        parent[root] = -1;
        int[] level = new int[tree.nVertex];
        level[root] = 0;
        while (front < back) {
            int v = queue[front++];
            for (int i = tree.first[v]; i != -1; i = tree.next[i]) {
                if (parent[v] != tree.to[i]) {
                    queue[back++] = tree.to[i];
                    level[tree.to[i]] = level[v] + 1;
                }
            }
        }
        return level;
    }
}

class ArrayUtils {

    public static int getMax(int[] a) {
        int result = a[0];
        for (int x : a) result = Math.max(result, x);
        return result;
    }

}


// practice with rainboy
import java.io.*;
import java.util.*;

public class CF414D extends PrintWriter {
	CF414D() { super(System.out, true); }
	Scanner sc = new Scanner(System.in);
	public static void main(String[] $) {
		CF414D o = new CF414D(); o.main(); o.flush();
	}

	int[] next, jj; int $ = 1;
	int[] ao, cc, aa;
	int link(int l, int j) {
		next[$] = l; jj[$] = j;
		return $++;
	}
	void init(int n, int m) {
		next = new int[1 + m * 2]; jj = new int[1 + m * 2];
		ao = new int[n]; cc = new int[n]; aa = new int[n];
	}
	void dfs(int p, int i, int d) {
		cc[d]++;
		for (int l = ao[i]; l != 0; l = next[l]) {
			int j = jj[l];
			if (j != p)
				dfs(i, j, d + 1);
		}
	}
	void main() {
		int n = sc.nextInt();
		int k = sc.nextInt();
		int p = sc.nextInt();
		init(n, n - 1);
		for (int h = 0; h < n - 1; h++) {
			int i = sc.nextInt() - 1;
			int j = sc.nextInt() - 1;
			ao[i] = link(ao[i], j);
			ao[j] = link(ao[j], i);
		}
		dfs(-1, 0, 0);
		int ans = 0, cnt = 0; long sum = 0;
		for (int d_ = 1, d = 1; d < n; d++) {
			int a = Math.min(cc[d], k); long b;
			aa[d] = a;
			k -= a;
			while (d_ < d && aa[d] < cc[d]) {
				a = Math.min(aa[d_], cc[d] - aa[d]);
				aa[d] += a;
				aa[d_] -= a; cnt -= a; sum -= (long) a * d_;
				if (aa[d_] == 0)
					d_++;
			}
			while ((b = (long) cnt * d - sum - p) > 0) {
				a = (int) Math.min(aa[d_], (b + d - d_ - 1) / (d - d_));
				k += a;
				aa[d_] -= a; cnt -= a; sum -= (long) a * d_;
				if (aa[d_] == 0)
					d_++;
			}
			ans = Math.max(ans, cnt + aa[d]);
			cnt += aa[d];
			sum += (long) aa[d] * d;
		}
		println(ans);
	}
}


import java.util.*;
import java.io.*;

public class Main {
    public static void main(String args[]) throws Exception {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        InputReader in = new InputReader(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        Task solver = new Task();
        solver.main(in, out);
        out.close();
    }
}

class Task {

    final int N = 21;
    final int maxn = 111111;
    final int mod = (int) (1e9 + 7);
    ArrayList<Integer>[] edge;
    boolean[] vis = new boolean[maxn];
    int[] cnt = new int[maxn];
    int most = 0;

    void dfs(int u, int dep) {
        most = Math.max(most, dep);
        vis[u] = true;
        cnt[dep]++;
        for (int v : edge[u]) {
            if (!vis[v]) {
                dfs(v, dep + 1);
            }
        }
    }

    @SuppressWarnings("unchecked")
    void main(InputReader in, PrintWriter out) throws Exception {
        int m, k, p, i;
        m = in.nextInt();
        k = in.nextInt();
        p = in.nextInt();
        edge = new ArrayList[m + 1];
        for (i = 0; i <= m; ++i) {
            edge[i] = new ArrayList<Integer>();
        }
        for (i = 1; i < m; ++i) {
            int u = in.nextInt();
            int v = in.nextInt();
            edge[u].add(v);
            edge[v].add(u);
        }
        dfs(1, 0);
        int sum = 0;
        int l = 1, r = 1;
        int size = 0, ans = 0;
        cnt[0] = 0;
        for(r=1;r<=most;++r){
            sum += size;
            while (sum > p) {
                sum -= cnt[l] * (r - l);
                size -= cnt[l];
                ++l;
            }
            size += cnt[r];
            int tmp = Math.min((p - sum) / (r - l + 1), cnt[l - 1]);
            ans = Math.max(ans, tmp + size);
        }
        ans = Math.min(ans, k);
        out.println(ans);
    }
}

class InputReader {
    BufferedReader reader;
    StringTokenizer tokenizer;

    InputReader(InputStream stream) {
        reader = new BufferedReader(new InputStreamReader(stream));
        tokenizer = null;
    }

    String next() {
        if (!hasNext())
            throw new RuntimeException();
        return tokenizer.nextToken();
    }

    boolean hasNext() {
        while (tokenizer == null || !tokenizer.hasMoreTokens())
            try {
                tokenizer = new StringTokenizer(reader.readLine());
            } catch (Exception e) {
                return false;
            }
        return true;
    }

    int nextInt() {
        return Integer.parseInt(next());
    }

    long nextLong() {
        return Long.parseLong(next());
    }
}


import java.util.*;
import java.io.*;

public class Main {
	public static void main(String args[]) throws Exception {
		InputStream inputStream = System.in;
		OutputStream outputStream = System.out;
		InputReader in = new InputReader(inputStream);
		PrintWriter out = new PrintWriter(outputStream);
		Task solver = new Task();
		solver.main(in, out);
		out.close();
	}
}

class Task {

	final int N = 21;
	final int maxn = 111111;
	final int mod = (int) (1e9 + 7);
	ArrayList<Integer>[] edge;
	boolean[] vis = new boolean[maxn];
	int[] cnt = new int[maxn];
	int most = 0;

	void dfs(int u, int dep) {
		most = Math.max(most, dep);
		vis[u] = true;
		cnt[dep]++;
		for (int v : edge[u]) {
			if (!vis[v]) {
				dfs(v, dep + 1);
			}
		}
	}

	@SuppressWarnings("unchecked")
	void main(InputReader in, PrintWriter out) throws Exception {
		int m, k, p, i;
		m = in.nextInt();
		k = in.nextInt();
		p = in.nextInt();
		edge = new ArrayList[m + 1];
		for (i = 0; i <= m; ++i) {
			edge[i] = new ArrayList<Integer>();
		}
		for (i = 1; i < m; ++i) {
			int u = in.nextInt();
			int v = in.nextInt();
			edge[u].add(v);
			edge[v].add(u);
		}
		dfs(1, 0);
		int sum = 0;
		int l = 1, r = 1;
		int size = 0, ans = 0;
		cnt[0] = 0;
		while (r <= most) {
			sum += size;
			while (sum > p) {
				sum -= cnt[l] * (r - l);
				size -= cnt[l];
				++l;
			}
			size += cnt[r++];
			int tmp = Math.min((p - sum) / (r - l + 1), cnt[l - 1]);
			ans = Math.max(ans, tmp + size);
		}
		ans = Math.min(ans, k);
		out.println(ans);
	}
}

class InputReader {
	BufferedReader reader;
	StringTokenizer tokenizer;

	InputReader(InputStream stream) {
		reader = new BufferedReader(new InputStreamReader(stream));
		tokenizer = null;
	}

	String next() {
		if (!hasNext())
			throw new RuntimeException();
		return tokenizer.nextToken();
	}

	boolean hasNext() {
		while (tokenizer == null || !tokenizer.hasMoreTokens())
			try {
				tokenizer = new StringTokenizer(reader.readLine());
			} catch (Exception e) {
				return false;
			}
		return true;
	}

	int nextInt() {
		return Integer.parseInt(next());
	}

	long nextLong() {
		return Long.parseLong(next());
	}
}


import java.io.*;
import java.util.*;
import java.math.*;

public class D implements Runnable {
	static BufferedReader in;
	static PrintWriter out;
	static StringTokenizer st;
	static Random rnd;

	private void solve() throws IOException {
		int vertexesCount = nextInt();
		int waterCount = nextInt(), moneyCount = nextInt();
		int[] heightsCount = new int[vertexesCount];
		List<Integer>[] g = new List[vertexesCount];
		for (int i = 0; i < vertexesCount; i++) {
			g[i] = new ArrayList<Integer>();
		}
		for (int i = 1; i < vertexesCount; i++) {
			int u = nextInt() - 1, v = nextInt() - 1;
			g[u].add(v);
			g[v].add(u);
		}
		dfs(0, -1, 0, heightsCount, g);
		int result = 0, cursor = vertexesCount - 1;
		int takenCount = 0, remainMoney = moneyCount;
		for (int i = vertexesCount - 1; i > 0; i--) {
			if (cursor > i)
				throw new AssertionError();

			while (cursor > 0
					&& (waterCount - takenCount) >= heightsCount[cursor]
					&& (i - cursor) * (long) heightsCount[cursor] <= remainMoney) {
				takenCount += heightsCount[cursor];
				remainMoney -= (i - cursor) * heightsCount[cursor];
				--cursor;
			}

			{
				int canTail = 0;
				if (cursor > 0) {
					canTail = Math.min(waterCount - takenCount,
							heightsCount[cursor]);
					if (i != cursor)
						canTail = Math.min(canTail, remainMoney / (i - cursor));
				}
				result = Math.max(result, takenCount + canTail);
			}

			if (cursor < i) {
				takenCount -= heightsCount[i];
				remainMoney += takenCount;
			} else {
				--cursor;
			}
		}
		out.println(result);
	}

	private void dfs(int u, int p, int h, int[] heightsCount, List<Integer>[] g) {
		heightsCount[h]++;
		for (int v : g[u]) {
			if (v != p)
				dfs(v, u, h + 1, heightsCount, g);
		}
	}

	public static void main(String[] args) {
		// final boolean oldChecker = false;
		//
		// if (oldChecker)
		// new Thread(null, new Template(), "yarrr", 1 << 24).start();
		// else
		new D().run();
	}

	public void run() {
		try {
			final String className = this.getClass().getName().toLowerCase();

			try {
				in = new BufferedReader(new FileReader(className + ".in"));
				out = new PrintWriter(new FileWriter(className + ".out"));
				// in = new BufferedReader(new FileReader("input.txt"));
				// out = new PrintWriter(new FileWriter("output.txt"));
			} catch (FileNotFoundException e) {
				in = new BufferedReader(new InputStreamReader(System.in));
				out = new PrintWriter(System.out);
			}

			rnd = new Random();

			solve();

			out.close();
		} catch (IOException e) {
			e.printStackTrace();
			System.exit(1);
		}
	}

	private String nextToken() throws IOException {
		while (st == null || !st.hasMoreTokens()) {
			String line = in.readLine();

			if (line == null)
				return null;

			st = new StringTokenizer(line);
		}

		return st.nextToken();
	}

	private int nextInt() throws IOException {
		return Integer.parseInt(nextToken());
	}

	private long nextLong() throws IOException {
		return Long.parseLong(nextToken());
	}

	private double nextDouble() throws IOException {
		return Double.parseDouble(nextToken());
	}
}


import java.io.*;
import java.util.*;
import java.math.*;

public class D implements Runnable {
	static BufferedReader in;
	static PrintWriter out;
	static StringTokenizer st;
	static Random rnd;

	private void solve() throws IOException {
		int vertexesCount = nextInt();
		int waterCount = nextInt(), moneyCount = nextInt();
		int[] heightsCount = new int[vertexesCount];
		List<Integer>[] g = new List[vertexesCount];
		for (int i = 0; i < vertexesCount; i++) {
			g[i] = new ArrayList<Integer>();
		}
		for (int i = 1; i < vertexesCount; i++) {
			int u = nextInt() - 1, v = nextInt() - 1;
			g[u].add(v);
			g[v].add(u);
		}
		dfs(0, -1, 0, heightsCount, g);
		int result = 0, cursor = vertexesCount - 1;
		int takenCount = 0, remainMoney = moneyCount;
		for (int i = vertexesCount - 1; i > 0; i--) {
			if (cursor > i)
				throw new AssertionError();

			while (cursor > 0
					&& (waterCount - takenCount) >= heightsCount[cursor]
					&& (i - cursor) * (long) heightsCount[cursor] <= remainMoney) {
				takenCount += heightsCount[cursor];
				remainMoney -= (i - cursor) * heightsCount[cursor];
				--cursor;
			}

			{
				int canTail = 0;
				if (cursor > 0) {
					Math.min(waterCount - takenCount, heightsCount[cursor]);
					if (i != cursor)
						canTail = Math.min(canTail, remainMoney / (i - cursor));
				}
				result = Math.max(result, takenCount + canTail);
			}

			if (cursor < i) {
				takenCount -= heightsCount[i];
				remainMoney += takenCount;
			} else {
				--cursor;
			}
		}
		out.println(result);
	}

	private void dfs(int u, int p, int h, int[] heightsCount, List<Integer>[] g) {
		heightsCount[h]++;
		for (int v : g[u]) {
			if (v != p)
				dfs(v, u, h + 1, heightsCount, g);
		}
	}

	public static void main(String[] args) {
		// final boolean oldChecker = false;
		//
		// if (oldChecker)
		// new Thread(null, new Template(), "yarrr", 1 << 24).start();
		// else
		new D().run();
	}

	public void run() {
		try {
			final String className = this.getClass().getName().toLowerCase();

			try {
				in = new BufferedReader(new FileReader(className + ".in"));
				out = new PrintWriter(new FileWriter(className + ".out"));
				// in = new BufferedReader(new FileReader("input.txt"));
				// out = new PrintWriter(new FileWriter("output.txt"));
			} catch (FileNotFoundException e) {
				in = new BufferedReader(new InputStreamReader(System.in));
				out = new PrintWriter(System.out);
			}

			rnd = new Random();

			solve();

			out.close();
		} catch (IOException e) {
			e.printStackTrace();
			System.exit(1);
		}
	}

	private String nextToken() throws IOException {
		while (st == null || !st.hasMoreTokens()) {
			String line = in.readLine();

			if (line == null)
				return null;

			st = new StringTokenizer(line);
		}

		return st.nextToken();
	}

	private int nextInt() throws IOException {
		return Integer.parseInt(nextToken());
	}

	private long nextLong() throws IOException {
		return Long.parseLong(nextToken());
	}

	private double nextDouble() throws IOException {
		return Double.parseDouble(nextToken());
	}
}


import java.io.*;
import java.util.*;
import java.math.*;

public class D implements Runnable {
	static BufferedReader in;
	static PrintWriter out;
	static StringTokenizer st;
	static Random rnd;

	private void solve() throws IOException {
		int vertexesCount = nextInt();
		int waterCount = nextInt(), moneyCount = nextInt();
		int[] heightsCount = new int[vertexesCount];
		List<Integer>[] g = new List[vertexesCount];
		for (int i = 0; i < vertexesCount; i++) {
			g[i] = new ArrayList<Integer>();
		}
		for (int i = 1; i < vertexesCount; i++) {
			int u = nextInt() - 1, v = nextInt() - 1;
			g[u].add(v);
			g[v].add(u);
		}
		dfs(0, -1, 0, heightsCount, g);
		int result = 0;
		for (int startH = 1; startH < vertexesCount; startH++) {
			int currentResult = Math.min(waterCount, heightsCount[startH]);
			int remainWater = waterCount - currentResult, remainMoney = moneyCount;
			for (int j = startH - 1; j > 0; j--) {
				int oneCost = startH - j;
				int canTake = Math.min(remainWater,
						Math.min(remainMoney / oneCost, heightsCount[j]));
				currentResult += canTake;
				remainWater -= canTake;
				remainMoney -= canTake * oneCost;
			}
			result = Math.max(result, currentResult);
		}
		out.println(result);
	}

	private void dfs(int u, int p, int h, int[] heightsCount, List<Integer>[] g) {
		heightsCount[h]++;
		for (int v : g[u]) {
			if (v != p)
				dfs(v, u, h + 1, heightsCount, g);
		}
	}

	public static void main(String[] args) {
		// final boolean oldChecker = false;
		//
		// if (oldChecker)
		// new Thread(null, new Template(), "yarrr", 1 << 24).start();
		// else
		new D().run();
	}

	public void run() {
		try {
			final String className = this.getClass().getName().toLowerCase();

			try {
				in = new BufferedReader(new FileReader(className + ".in"));
				out = new PrintWriter(new FileWriter(className + ".out"));
				// in = new BufferedReader(new FileReader("input.txt"));
				// out = new PrintWriter(new FileWriter("output.txt"));
			} catch (FileNotFoundException e) {
				in = new BufferedReader(new InputStreamReader(System.in));
				out = new PrintWriter(System.out);
			}

			rnd = new Random();

			solve();

			out.close();
		} catch (IOException e) {
			e.printStackTrace();
			System.exit(1);
		}
	}

	private String nextToken() throws IOException {
		while (st == null || !st.hasMoreTokens()) {
			String line = in.readLine();

			if (line == null)
				return null;

			st = new StringTokenizer(line);
		}

		return st.nextToken();
	}

	private int nextInt() throws IOException {
		return Integer.parseInt(nextToken());
	}

	private long nextLong() throws IOException {
		return Long.parseLong(nextToken());
	}

	private double nextDouble() throws IOException {
		return Double.parseDouble(nextToken());
	}
}


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