#include <iostream>
#include <cstdio>
#include <vector>
#include <algorithm>

using namespace std;

typedef long long ll;

ll n;
ll a[100005];
vector<ll> ve[100005], now;
ll d[100005];
bool v[100005];

int main()
{
    scanf("%lld", &n);
    for(ll i = 2; i <= n; i++)
    {
        scanf("%lld", &a[i]);
        ve[a[i]].push_back(i);
    }
    for(ll i = n; i >= 1; i--)
    {
        ll t = 0;
        now.clear();
        d[i]--;
        for(ll j = 0; j < ve[i].size(); j++)
        {
            ll jj = ve[i][j];
            if(v[jj]) now.push_back(d[jj]);
            else if(d[jj] > 0) d[i] += d[jj];
            else t += d[jj];
        }
        if((ll)now.size() % 2 == 1) d[i] -= t, v[i] = false;
        else d[i] += t, v[i] = true;
        sort(now.begin(), now.end(), greater<int>());
        for(ll j = 0; j < (ll)now.size() - 1; j += 2) d[i] += now[j] - now[j + 1];
        if((ll)now.size() % 2 == 1) d[i] += now[now.size() - 1];
    }
    printf("%lld\n", (n - d[1]) / 2);
    return 0;
}

#include <bits/stdc++.h>
#include <iostream>
using namespace std;
#define ll long long
#define ld long double
#define mp make_pair
#define pb push_back
#define fo(i,n) for(ll i=0;i<n;i++)
#define fo1(i,n) for(ll i=1;i<=n;i++)
#define loop(i,a,b)for(ll i=a;i<=b;i++)
#define loopr(i,a,b)for(ll i=b;i>=a;i--)
#define vll vector<ll> 
#define vvl vector<vll>
#define pii pair<ll,ll>
#define F first
#define S second
#define M 1000000007
ll max(ll a,ll b){if (a>b) return a; else return b;}
ll min(ll a,ll b){if(a<b) return a; return b;}
ll mod=998244353;
 
ll po(ll x, ll y){
    if(y==0)
    return 1;
    if(y%2){
        return ((x)*(po(x,y/2)%M)*(po(x,y/2)%M) + M)%M;
    }
   return ((po(x,y/2)%M)*(po(x,y/2)%M) + M)%M;
}
 
void seive(bool prime[]){
    //bool prime[100002]; 
     
  
    for (ll p=2; p*p<=1000001; p++) 
    { 
        if (prime[p]) 
        { 
            for (ll i=p*p; i<=1000001; i+=p) 
                prime[i] = false; 
        } 
    }
}
    
ll powermod(ll x,ll y,ll p)  {
  ll res = 1;     
    x = x % p; 
 if (x == 0) return 0;  
    while (y > 0)  
    {     if (y & 1)  
            res = (res*x) % p;  
        y = y>>1; // y = y/2  
        x = (x*x) % p;  
    }  
    return res;  
}
 
ll gcd(ll x, ll y){
    if (y == 0)
    return x;
    else
    return gcd(y, x % y);
}
 
ll nck(ll n, ll k){
    ll C[k + 1];
    memset(C, 0, sizeof(C));
    C[0] = 1;
    for (ll i = 1; i <= n; i++) {
        for (ll j = min(i, k); j > 0; j--)
            C[j] = (C[j]%M + C[j - 1]%M)%M;
    }
    return C[k]%M;
}
 
/*void call(vll &primefactor,int N){
    for(int i=1;i<N;i++)
    {
        primefactor[i]=i;
    }
    for(int i=2;i<N;i++)
    {
        if(primefactor[i]!=i)  
            continue;
        for(int j=i;j<N;j+=i)
            primefactor[j]=i;  
    }
}*/
string divi(string number, int divisor)
{
    // As result can be very large store it in string
    string ans;
 
    // Find prefix of number that is larger
    // than divisor.
    int idx = 0;
    int temp = number[idx] - '0';
    while (temp < divisor)
        temp = temp * 10 + (number[++idx] - '0');
 
    // Repeatedly divide divisor with temp. After
    // every division, update temp to include one
    // more digit.
    while (number.size() > idx) {
        // Store result in answer i.e. temp / divisor
        ans += (temp / divisor) + '0';
 
        // Take next digit of number
        temp = (temp % divisor) * 10 + number[++idx] - '0';
    }
 
    // If divisor is greater than number
    if (ans.length() == 0)
        return "0";
 
    // else return ans
    return ans;
} 
int main(){
	ios_base::sync_with_stdio(0);
	cin.tie(0);
	cout.tie(0);
	ll t=1;
    //cin>>t;
    while(t--){
        string s; ll k; cin>>s>>k;
        fo(i,k){
            ll n=s.size();
            if(n>=3 && s[n-1]=='0' && s[n-2]=='0' && (s[n-3]-'0')%2==0){
                string kk=s.substr(0,n-2);
                s=divi(kk,2);
            }
            else
            s+="200";
        }
        cout<<s<<endl;
    }
    return 0;
}