#include <bits/stdc++.h>
#pragma GCC optimize("Ofast")
using namespace std;
const int N = 3e5 + 5;
vector<int> v[N];
int a[N], n, x, k;
int dfs(int nod) {
  if (!(int)((v[nod]).size())) return 0;
  if (a[nod]) {
    int val = INT_MIN;
    for (auto it : v[nod]) val = max(val, dfs(it));
    return val;
  } else {
    int val = -(int)((v[nod]).size()) + 1;
    for (auto it : v[nod]) val += dfs(it);
    return val;
  }
}
int32_t main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  cin >> n;
  for (int i = 1; i <= n; i++) cin >> a[i];
  for (int i = 2; i <= n; i++) {
    cin >> x;
    v[x].push_back(i);
  }
  for (int i = 1; i <= n; i++)
    if (!(int)((v[i]).size())) k++;
  cout << (k + dfs(1));
  return 0;
}
