#include<iostream>
#include<vector>
#include<algorithm>
#include<cstdio>
#include<string>
#include<stdio.h>
#include<stdlib.h>
#include<float.h>
#include<tuple>
#include<string.h>
#include<iomanip>
#include<stack>
#include<queue>
#include<map>
#include<deque>
#include<math.h>

using namespace std;
#define ll long long
#define rep(i,n) for(ll i=0;i<n;i++)
#define REP(i,n) for(ll i=1;i<=n;i++)
#define ALLOF(c) (c).begin(), (c).end()
#define Pa pair<ll,ll>
const ll mod=1000000007;
const ll INF=10e12;
const ll inf=-1;
ll ABS(ll a){return max(a,-a);}


int main(void){
    ll K,s3a,ansc=0,ansb=0,ansa=0;
    cin>>K;
    REP(i,K){
        if(i*i*i<=K) ansa++; 
    }

    //全部違う場合
    for(ll i=1;i<=ansa;i++){
        for(ll j=i+1;i*j<=K;j++){
            ll k=K/(i*j);
            if(j>=k) break;
            ansc+=k-j;
        }
    }
    
    //1つだけ同じ
    REP(i,sqrt(K)){
        ansb+=K/(i*i);
        if(i*i*i<=K) ansb--;
    }
  
    cout<<ansc*6+ansb*3+ansa<<endl;
    return 0;
}
#include<bits/stdc++.h>
using namespace std;

const int maxn = 1e5 + 2;

int subtree[maxn];
vector < int > adj[maxn];

int dfs(int v,int p){
  int ans = 1;
  subtree[v] = 1;
  if(adj[v].size() == 1 and p)
    return 1;
  vector < int > odd_maxcoins,even_maxcoins;

  for(auto child : adj[v]){
    if(child == p)
      continue;
    else{
      int max_coins = dfs(child, v);
      subtree[v] += subtree[child];
      if(subtree[child]%2)
        odd_maxcoins.push_back(2*max_coins-subtree[child]);
      else
        even_maxcoins.push_back(2*max_coins-subtree[child]);
    }
  }
  // take out all negative differences in even array
  // for(auto vertex : odd_maxcoins)
  //   cout<<vertex<<"  ";
  // cout<<"\n";


  sort(odd_maxcoins.begin(),odd_maxcoins.end());
  sort(even_maxcoins.begin(),even_maxcoins.end());

  int n1 = odd_maxcoins.size(),n2 = even_maxcoins.size();
  for(int i=0;i<n1;++i){
    if(i%2)
      ans -= odd_maxcoins[i];
    else
      ans += odd_maxcoins[i];
  }

  for(int i=0;i<n2;++i){
    if(even_maxcoins[i] < 0)
      ans+=even_maxcoins[i];
    else if(n1%2)
      ans-=even_maxcoins[i];
    else
      ans+=even_maxcoins[i];
  }
  // cout<<v<<"  "<<subtree[v]<<"  "<<ans<<"\n";

  return (ans + subtree[v])/2;
}

int main(){
  int n,p;
  cin>>n;
  for(int i=2;i<=n;++i){
    cin>>p;
    adj[i].push_back(p);
    adj[p].push_back(i);
  }
  cout<<dfs(1,0);
  return 0;
}
