#include <iostream>
#include<bits/stdc++.h>
using namespace std;
pair<int,int> dol[100001];
vector<pair<int,int> > v;
vector<int> sused[100001];
void dfs(int s,int pret)
{
    int i,maximum=-1,br=0;
    if(sused[s].size()==1)
        dol[s]=make_pair(0,1);
    else
    {
        for(i=0;i<sused[s].size();i++)
        {
            if(sused[s][i]!=pret)
                dfs(sused[s][i],s);
        }
        for(i=0;i<sused[s].size();i++)
        {
            if(sused[s][i]!=pret)
            {
                if(dol[sused[s][i]].first+1>maximum)
                {
                    maximum=dol[sused[s][i]].first+1;
                    br=dol[sused[s][i]].second;
                }
                else
                {
                    if(dol[sused[s][i]].first+1==maximum)
                        br=br+dol[sused[s][i]].second;
                }
            }
        }
        dol[s]=make_pair(maximum,br);
    }
}
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    int bruk,br1=0,br2=0,brkec=0,d,c1,c2,n,i,maxpov=0,cvor=0;
    cin >> n;
    for(i=1;i<n;i++)
    {
        cin >> c1 >> c2;
        sused[c1].push_back(c2);
        sused[c2].push_back(c1);
    }
    for(i=1;i<n;i++)
    {
        //cin >> c1 >> c2;
        if(sused[i].size()>maxpov)
        {
            cvor=i;
            maxpov=sused[i].size();
        }
    }
    for(i=0;i<sused[cvor].size();i++)
    {
        dfs(sused[cvor][i],cvor);
        v.push_back(make_pair(dol[sused[cvor][i]].first+1,dol[sused[cvor][i]].second));
    }
    int m,pom;
    sort(v.begin(),v.end());
    m=v.size();
    d=v[m-1].first+v[m-2].first;
    cout << d << endl;
    i=m-1;
    pom=v[m-1].first;
    while(pom==v[i].first && i>=0)
    {
        br1=br1+v[i].second;
        i--;
    }
    if(i==m-2)
    {
        if(br1==1)
        {
            if(n%2==0)
                d--;
            else
            {
                pom=v[i].first;
                while(v[i].first==pom && i>=0)
                {
                    br2=br2+v[i].second;
                    i--;
                }
                if(br2==1)
                    d--;
                else
                {
                    if(n%2==0)
                        d--;
                }
            }
        }
        else
        {
            pom=v[i].first;
            while(v[i].first==pom)
            {
                br2=br2+v[i].second;
                i--;
            }
            if(br2==1)
            {
                if(n%2==0)
                    d--;
            }
        }
    }
    else
    {
        for(c1=i+1;c1<m;c1++)
            if(v[c1].second==1)
                brkec++;
        bruk=m-c1;
        if(brkec==bruk)
        {
            if(n%2==0)
            {
                if(brkec<=3)
                    d--;
            }
            else
            {
                if(brkec==2)
                {
                    d--;
                    //reseno=true;
                }
            }
        }
        else
        {
            if(bruk==2)
            {
                if(brkec==1)
                {
                    if(n%2==0)
                        d--;
                    //reseno=true;
                }
            }
        }
    }
    cout << d;
    //cout << cvor << endl;
    //for(i=0;i<v.size();i++)
      //  cout << v[i].first << " " << v[i].second << endl;
    //cout << "Hello world!" << endl;
    return 0;
}