#include <bits/stdc++.h>
using namespace std;

int main(){
  int N;
  cin >> N;
  vector<int64_t> A(N);
  for(int i=0; i<N; i++)
    cin >> A.at(i);

  int64_t o=0, x, ans=INT64_MAX;
  for(int64_t bit=0; bit<(1<<N); bit++){
    bit |= 1<<(N-1);
    x = 0;
    for(int i=0; i<N; i++){
      o |= A.at(i);
      if(1 & (bit>>i)){
	x ^= o;
	o = 0;
      }
    }
    ans = min(ans, x);
  }
  cout << ans << endl;

  return 0;
}

#include <bits/stdc++.h>
using namespace std;
#if __has_include(<atcoder/all>)
#include <atcoder/all>
using namespace atcoder;
#endif
using ll = long long;
using ld = long double;
#define all(s) (s).begin(),(s).end()
#define vcin(n) for(ll i=0;i<ll(n.size());i++) cin>>n[i]
#define rep2(i, m, n) for (int i = (m); i < (n); ++i)
#define rep(i, n) rep2(i, 0, n)
#define drep2(i, m, n) for (int i = (m)-1; i >= (n); --i)
#define drep(i, n) drep2(i, n, 0)
#define rever(vec) reverse(vec.begin(), vec.end())
#define sor(vec) sort(vec.begin(), vec.end())
#define fi first
#define se second
#define P pair<ll,ll>
const ll mod = 998244353;
//const ll mod = 1000000007;
const ll inf = 2000000000000000000ll;
static const long double pi = 3.141592653589793;
void YesNo(bool a){if(a){cout<<"Yes"<<endl;}else{cout<<"No"<<endl;}}
void YESNO(bool a){if(a){cout<<"YES"<<endl;}else{cout<<"NO"<<endl;}}
template<class T,class U> void chmax(T& t,const U& u){if(t<u) t=u;}
template<class T,class U> void chmin(T& t,const U& u){if(t>u) t=u;}
ll modPow(ll a, ll n, ll mod) { ll ret = 1; ll p = a % mod; while (n) { if (n & 1) ret = ret * p % mod; p = p * p % mod; n >>= 1; } return ret; }

vector<ll> g[100100];
ll ans[100100];
ll seen[100100];
ll t[100100];
ll dfs(ll a){
  if(seen[a]==1){
    return ans[a];
  }
  ll ansi=1;
  seen[a]=1;
  t[a]=1;
  ll p1=0,p2=0;
  vector<ll> k;
  vector<ll> gu;
  for(auto e:g[a]){
    auto p=dfs(e);
    t[a]+=t[e];
    if((t[e])%2){
      k.push_back(p);
    }
    else{
      if(p<0){
        p1+=p;
      }
      else{
        p2+=p;
      }
    }
  }
  sor(k);
  ansi+=p1;
//  cout<<"ANS"<<" "<<a<<" "<<ansi<<endl;
  for(int i=0;i<int(k.size());i++){
 //   cout<<"K"<<" "<<k[i]<<endl;
    if((i)%2==0){
      ansi+=k[i];
    }
    else{
      ansi-=k[i];
    }
  }
  if(int(k.size())%2==0){
    ansi+=p2;
  }
  else{
    ansi-=p2;
  }
 // cout<<p1<<" "<<p2<<endl;
  return ans[a]=ansi;
}
int main() {
  /* mod は 1e9+7 */
  ios::sync_with_stdio(false);
    std::cin.tie(nullptr);
  cout<< fixed << setprecision(10);
  ll a;
  cin>>a;
  for(int i=1;i<a;i++){
    ll x;
    cin>>x;
    x--;
    g[x].push_back(i);
  }
  for(int i=0;i<a;i++){
    seen[i]=0;
    t[i]=0;
  }
  dfs(0);
  for(int i=0;i<a;i++){
   // cout<<t[i]<<" "<<ans[i]<<endl;
  }
  cout<<(a+ans[0])/2<<endl;
}