#include <bits/stdc++.h>
template<class T> inline bool chmin(T&a, T b){if(a > b){a = b; return true;}else{return false;}}
template<class T> inline bool chmax(T&a, T b){if(a < b){a = b; return true;}else{return false;}}
#define ll long long
#define double long double
#define rep(i,n) for(int i=0;i<(n);i++)
#define REP(i,n) for(int i=1;i<=(n);i++)
#define mod (ll)(1e9+7)
#define inf (ll)(3e18+7)
#define eps (double)(1e-9)
#define pi (double) acos(-1)
#define P pair<int,int>
#define PiP pair<int,pair<int,int>>
#define all(x) x.begin(),x.end()
#define rall(x) x.rbegin(),x.rend()
using namespace std;

int n;
vector<vector<int>> G(100010);

//ret = First - Second
//rに動かした人がplayer == 0, player == 1なら交代

P solve(int r){
    int ret = 1;
    int player = 1, cnt = 0;
    priority_queue<int> que;
    for(auto v : G[r]){
        P now = solve(v);
        if(!now.second && now.first < 0)ret += now.first;
        if(!now.second && now.first > 0)cnt += now.first;
        if(now.second)que.push(-now.first);
    }
    while(!que.empty()){
        int t = -que.top();
        que.pop();
        if(player)ret += t;
        else ret -= t;
        player ^= 1;
    }
    if(player)ret += cnt;
    else ret -= cnt;
    return {ret, player};
}

int main() {
    cin >> n;
    rep(i, n-1){
        int p;
        cin >> p;
        G[p-1].push_back(i+1);
    }
    cout << (n+solve(0).first)/2 << endl;
}
#define fast ios::sync_with_stdio(false); cin.tie(0)
#define foru(i, k, n) for (int i = k; i < n; i++)
#define ford(i, k, n) for (int i = k; i >= n; i--)
#define pb push_back
#define ff first
#define ss second

#include <iostream>
#include <vector>
#include <algorithm>
#include <bitset>
#include <queue>

using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;


int main() {
	fast;
	int n;
	cin >> n;
	vector<ll> a(n, 0), b = a;
	foru(i, 0, n)cin >> a[i];
	foru(i, 0, n)cin >> b[i];
	ll sm = 0;
	foru(i, 0, n)sm += (a[i] * b[i]);
	if (sm == 0)cout << "Yes";
	else cout << "No";
	return 0;
}