#include <iostream>
#include <cassert>
#include <climits>
#include <bitset>
#include <stack>
#include <queue>
#include <iomanip>
#include <limits>
#include <string>
#include <cmath>
#include <set>
#include <map>
#include <math.h>
#include <algorithm>
#include <vector>
#include <string.h>

using namespace std;

typedef long long ll;
typedef pair<ll,ll> P;

long long int INF = 3e18;
long long int mod = 4294967296;
double Pi = 3.1415926535897932384626;

vector<ll> G[500005];
vector<P> tree[500010];
priority_queue <ll> pql;
priority_queue <P> pqp;
//big priority queue
priority_queue <ll,vector<ll>,greater<ll> > pqls;
priority_queue <P,vector<P>,greater<P> > pqps;
//small priority queue
//top pop

int dx[8]={1,0,-1,0,1,1,-1,-1};
int dy[8]={0,1,0,-1,1,-1,-1,1};
char dir[] = "DRUL";
//ll bit[500005];
//↓,→,↑,←


#define p(x) cout<<x<<endl;
#define el cout<<endl;
#define pe(x) cout<<x<<" ";
#define ps(x) cout<<fixed<<setprecision(15)<<x<<endl;
#define pu(x) cout<<x;
#define re(i,n) for(i=0;i<n;i++);
#define pb push_back
#define lb lower_bound
#define ub upper_bound
#define deba(x) cout<< #x << " = " << x <<endl


ll rui(ll abc,ll bed){
    //abcのbed乗を計算する
    if(bed==0){return 1;}
    else{
        ll ced = rui(abc,bed/2);
        ced *= ced;
        ced %= mod;
        if(bed%2==1){ced*=abc; ced%=mod;}
        return ced;
    }
}
ll gcd(ll number1,ll number2){
    if(number1 > number2){
        swap(number1,number2);
    }
    if(number1 == 0 || number1 == number2){
        return number2;
    }else{
        return gcd(number2 % number1,number1);
    }
}
void YES(bool condition){
    if(condition){
        p("YES");
    }else{
        p("NO");
    }
    return;
}
void Yes(bool condition){
    if(condition){
        p("Yes");
    }else{
        p("No");
    }
    return;
}

ll n,m,num,sum,ans,a,b,c,d,e,f,g,h,i,j,k,w,ok,ng;
ll t[500005],l[500005],r[500005];
ll dp[5005][5005][3];
bool flag,dame;

ll solve(ll node,ll parent,ll length){
	//nodeを見ている
	//親がparent
	//length以下にする
	vector <ll> table;
	for(int i=0;i<G[node].size();i++){
		if(G[node][i] == parent)continue;
		ll b = solve(G[node][i],node,length);
		if(b != -1){
			table.pb(b);
		}
	}
	if(G[node].size() % 2 == 1)table.pb(0ll);
	sort(table.begin(),table.end());
	bool flag = false;
	c = -1;
	if(table.size() % 2 == 0)flag = true;
	while(table.size() >= 2){
		a = table.back();
		table.pop_back();
		ll de = lb(table.begin(),table.end(),length - a + 1) - table.begin();
		de--;
		if(de < 0 && !flag){
			flag = true;
			c = a;
		}else if(de < 0){
			dame = true;
			return INF;
		}else{
			table.erase(table.begin() + de);
		}
	}
	if(c != -1){
		table.pb(c);
	}
	if(table.size() == 1){
		return table[0] + 1;
	}else{
		return -100;
	}
}


int main(){
    cin >> n;
	for(i=0;i<n-1;i++){
		cin >> a >> b;
		G[a].pb(b);
		G[b].pb(a);
	}
	a = 0;
	for(i=1;i<=n;i++){
		if(G[i].size() % 2 == 1){
			a++;
		}
	}
	num = 1;
	assert(a % 2 == 0);
	a /= 2;
	pe(a);
	ng = -1;
	ok = n + 10;
	while(ok - ng > 1){
		ll mid = (ok + ng) / 2;
		//pe(mid);
		dame = false;
		ll ans = solve(num,-1,mid);
		//assert(ans == 0 || ans == INF);
		//p(ans);
		if(dame || ans != -100){
			ng = mid;
		}else{
			ok = mid;
		}
	}
	p(ok);
	return 0;
}

Measured memory_bytes: 36992