#include <bits/stdc++.h>
using namespace std;
const long long lim = 1e6;
const long long MOD = 1e9 + 7;
long long rd() {
  long long x;
  scanf("%lld", &x);
  return x;
}
const int maxn = 3e5 + 5;
vector<int> e[maxn];
int a[maxn], d[maxn];
int cnt, n;
void dfs(int u) {
  if (e[u].empty()) {
    d[u] = 1;
    cnt++;
    return;
  }
  d[u] = a[u] ? n : 0;
  for (auto v : e[u]) {
    dfs(v);
    if (a[u])
      d[u] = min(d[u], d[v]);
    else
      d[u] += d[v];
  }
}
int main() {
  n = rd();
  for (int i = 1; i <= n; i++) a[i] = rd();
  for (int i = 2; i <= n; i++) {
    int x = rd();
    e[x].push_back(i);
  }
  dfs(1);
  printf("%d", cnt + 1 - d[1]);
}
