//#define _GLIBCXX_DEBUG
//#include "atcoder/all"
//using namespace atcoder;
#include <bits/stdc++.h>
#define int long long
#define ll long long
using ull = unsigned long long;
using namespace std;
#define Dump(x)                             \
    if (dbg) {                              \
        cerr << #x << " = " << (x) << endl; \
    }
#define overload4(_1, _2, _3, _4, name, ...) name
#define FOR1(n) for (ll i = 0; i < (n); ++i)
#define FOR2(i, n) for (ll i = 0; i < (n); ++i)
#define FOR3(i, a, b) for (ll i = (a); i < (b); ++i)
#define FOR4(i, a, b, c) for (ll i = (a); i < (b); i += (c))
#define FOR(...) overload4(__VA_ARGS__, FOR4, FOR3, FOR2, FOR1)(__VA_ARGS__)
#define FORR(i, a, b) for (int i = (a); i <= (b); ++i)
#define bit(n, k) (((n) >> (k)) & 1) /*nのk bit目*/
namespace mydef {
const int INF = 1ll << 60;
const int MOD = 1e9 + 7;
template <class T>
bool chmin(T& a, const T& b) {
    if (a > b) {
        a = b;
        return 1;
    } else
        return 0;
}
template <class T>
bool chmax(T& a, const T& b) {
    if (a < b) {
        a = b;
        return 1;
    } else
        return 0;
}
void Yes(bool flag = true) {
    if (flag)
        cout << "Yes" << endl;
    else
        cout << "No" << endl;
}
void No(bool flag = true) {
    Yes(!flag);
}
void YES(bool flag = true) {
    if (flag)
        cout << "YES" << endl;
    else
        cout << "NO" << endl;
}
void NO(bool flag = true) {
    YES(!flag);
}
template <typename A, size_t N, typename T>
void Fill(A (&array)[N], const T& val) {
    std::fill((T*)array, (T*)(array + N), val);
}
bool dbg = true;
}  // namespace mydef
using namespace mydef;
#define pb push_back
//#define mp make_pair
#define eb emplace_back
#define lb lower_bound
#define ub upper_bound
#define all(v) (v).begin(), (v).end()
#define SZ(x) ((int)(x).size())
#define vi vector<int>
#define vvi vector<vector<int>>
#define vp vector<pair<int, int>>
#define vvp vector<vector<pair<int, int>>>
#define pi pair<int, int>
//#define P pair<int, int>
//#define V vector<int>
//#define S set<int>
#define asn ans

int N;
vi G[101010];

pair<pi, bool> f(int now) {  //first : 先手が取る石の数(先手は道を選べない方), second : 後手が取る石の数(最大化したいのはこれ) //最後 true:同じ, false:変わる
    vp V_same, V_chg;
    for (auto& nxt : G[now]) {
        auto p = f(nxt);
        if (p.second)
            V_same.emplace_back(p.first);
        else
            V_chg.emplace_back(p.first);
    }
    pi ret{1, 0};

    vp V_rem;
    for (auto& p : V_same) {
        if (p.second > p.first) {
            ret.first += p.first;
            ret.second += p.second;
        } else {
            V_rem.emplace_back(p);
        }
    }

    sort(all(V_chg), [](pi a, pi b) { return a.second - a.first > b.second - b.first; });
    for (int i = 0; i < V_chg.size(); i++) {
        auto p = V_chg[i];
        if (i % 2 == 0) {
            ret.first += p.first;
            ret.second += p.second;
        } else {
            ret.first += p.second;
            ret.second += p.first;
        }
    }

    bool player_same = V_chg.size() % 2 == 0;

    for (auto& p : V_rem) {
        if (player_same) {
            //後手が後手のまま
            ret.first += p.first;
            ret.second += p.second;
        } else {
            ret.first += p.second;
            ret.second += p.first;
        }
    }

    //cout << now << " : " << ret.first << " " << ret.second << endl;
    return {ret, !player_same};
}

void solve() {
    cout << f(0).first.first << endl;
}

signed main() {
    cin.tie(nullptr);
    ios::sync_with_stdio(false);

    cin >> N;
    for (int i = 1; i < N; i++) {
        int p;
        cin >> p;
        p--;
        G[p].emplace_back(i);
    }

    solve();
    return 0;
}

#include<bits/stdc++.h>
using namespace std;
// #include <ext/pb_ds/assoc_container.hpp> 
// #include <ext/pb_ds/detail/standard_policies.hpp>
// using namespace __gnu_pbds;

#pragma GCC optimize("O3")
#ifdef LOCAL
#include "/Users/lbjlc/Desktop/coding/debug_utils.h"
#else
#define print(...) ;
#define printn(...) ;
#define printg(...) ;
#define fprint(...) ;
#define fprintn(...) ;
#endif

#define rep(i, a, b) for(auto i = (a); i < (b); i++)
#define rrep(i, a, b) for(auto i = (a); i > (b); i--)
#define all(v) (v).begin(), (v).end()
#define pb push_back
// #define mp make_pair
#define fi first
#define se second
#define maxi(x, y) x = max(x, y)
#define mini(x, y) x = min(x, y)
// long long fact(long long n) { if(!n) return 1; return n*fact(n-1); }
// #define endl '\n'
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
int get_random() {
    static uniform_int_distribution<int> dist(0, 1e9 + 6);
    return dist(rng);
}
const vector<pair<int,int>> eight_directions = {{1,1},{1,0},{1,-1},{0,1},{0,-1},{-1,1},{-1,0},{-1,-1}};
const vector<pair<int,int>> four_directions = {{1,0},{0,1},{0,-1},{-1,0}};
#define solve_testcase int T;cin>>T;for(int t=1;t<=T;t++){solve(t);}


typedef unsigned long long ull;
typedef long long ll;
 
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef pair<double, double> pdd;
 
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<vvi> vvvi;
typedef vector<pii> vpii;
typedef vector<pll> vpll;
typedef vector<pdd> vpdd;
typedef vector<long long> vll;
#define bd(type,op,val) bind(op<type>(), std::placeholders::_1, val)

template<class T>
void make_unique(T & v) {
    sort(v.begin(), v.end()); v.erase(unique(v.begin(), v.end()), v.end());
}
int geti() { int x; cin >> x; return x; }
long long getll() { long long x; cin >> x; return x; }
double getd() { double x; cin >> x; return x; }
// pair<int, int> a(geti(), geti()) does not work
// pair<int, int> a({geti(), geti()}) works, since it uses initializer.

const int MAXN = 3e5 + 100;

void solve(int tt) {
    // cout<<"Case #"<<tt<<": ";
}

int n;
vi graph[MAXN];
int cnt[MAXN] = {}, coins[MAXN] = {};

int dfs0(int i, int p) {
	cnt[i] = 1;
	for(auto j: graph[i]) {
		if(j != p) {
			cnt[i] += dfs0(j, i);
		}
	}
	return cnt[i];
}

int dfs1(int i, int p) {
	vi tmp1, tmp0;
	for(auto j:graph[i]) {
		if(j == p) continue;
		int tmp = dfs1(j, i);
		if(cnt[j] % 2) tmp1.pb(tmp);
		else tmp0.pb(tmp);
	}
	int res = 1;
	int sign = tmp1.size() % 2 == 1 ? -1 : 1;
	for(auto x:tmp0) {
		if(x <= 0) res += x;
		else res += sign * x;
	}
	sort(all(tmp1));

	for(int i = 0; i < tmp1.size(); i++) {
		res += tmp1[i] * (i % 2 == 0 ? 1 : -1);
	}

	coins[i] = res;
	return res;
}

int main(int argc, char * argv[]) {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    cout.tie(nullptr);
    // solve_testcase;

    cin>>n;
    int tmp;
    rep(i,2,n + 1) {
    	cin>>tmp;
    	graph[i].pb(tmp);
    	graph[tmp].pb(i);
    }

    dfs0(1,-1);
    dfs1(1, -1);

    printn(coins+1,n);
    cout<<(coins[1] + cnt[1]) / 2<<endl;


    return 0;
}











