#include<iostream>
#include<vector>
#include<queue>
using namespace std;

int func(int v,vector<vector<int>>& T,vector<bool>& F) {
  priority_queue<int> q1,q2,q3;
  int i;
  F[v] = true;
  for(i=0;i<T[v].size();i++) {
    int temp = func(T[v][i],T,F);
    if(F[T[v][i]])q2.push(temp);
    else if(temp > 0)q1.push(temp);
    else q3.push(temp);
    if(F[T[v][i]])F[v] = !F[v];
  }
  int ans = -1;
  while(!q1.empty()) {
    ans += q1.top();
    q1.pop();
  }
  for(i=0;!q2.empty();i++) {
    ans += (i%2>0?-1:1)*q2.top();
    q2.pop();
  }
  while(!q3.empty()) {
    ans += (i%2>0?-1:1)*q3.top();
    q3.pop();
  }
  return ans;
}

int main() {
  int N;
  cin >> N;
  vector<vector<int>> T(N);
  vector<bool> F(N);
  int i,p;
  for(i=1;i<N;i++) {
    cin >> p;
    T[p-1].push_back(i);
  }
  cout << ((N-func(0,T,F))/2) << endl;
}
#include <bits/stdc++.h>
using namespace std;
#define int long long
using vec_int = vector<int>;
using P = pair<int,int>;
using T = tuple<int,int,int>;
using ll = long long;
#define rep(i, n) for(int i = 0; i < (int)(n); i++)

int charToInt(char c){
    char zero_num = '0';
    return (int)c - (int)zero_num;
}

signed main(){
    int N; cin>>N;
    int M; cin>>M;
    vec_int a(M);
    vec_int b(M);
    rep(i,M)cin>>a.at(i)>>b.at(i);
    vec_int c(N); rep(i,N)cin>>c.at(i);
    vector<vec_int> G(N+1);
    rep(i,M){
        G.at(a.at(i)).push_back(b.at(i));
        G.at(b.at(i)).push_back(a.at(i));
    }
    map<P, int> path_map;
    rep(i, M){
        path_map[make_pair(a.at(i), b.at(i))] = i;
        path_map[make_pair(b.at(i), a.at(i))] = i;
    }
    vector<string> ans(M,"");
    rep(i,M){
        if(c.at(a.at(i)-1)>c.at(b.at(i)-1)){
            ans.at(i) = "->";
        }else if(c.at(a.at(i)-1)<c.at(b.at(i)-1)){
            ans.at(i) = "<-";
        }
    }

    rep(i,M){
        if(ans.at(i)==""){
            vec_int visited(N+1, 0);
            visited.at(a.at(i)) =1;
            stack<P> st;
            st.push(make_pair(b.at(i), a.at(i))); // node, parent
            int node_val = c.at(a.at(i)-1);
            while(!st.empty()){
                int node = st.top().first;
                int parent = st.top().second;
                st.pop();
                int ind = path_map[make_pair(parent, node)];
                if(ans.at(ind)!="")continue;
                if(a.at(ind)==parent && b.at(ind)==node){
                    ans.at(ind) = "->";
                }else{
                    ans.at(ind) = "<-";
                }
                for(auto next_node: G.at(node)){
                    if(next_node==parent)continue;
                    if(c.at(next_node-1)!=node_val)continue;
                    st.push(make_pair(next_node, node));
                }
            }
        }
    }
    rep(i,M){
        cout<<ans.at(i)<<endl;
    }







    return 0;
}