#include <bits/stdc++.h>
using namespace std;
struct edge {
  int to, next;
} e[300003 << 1];
int head[300003], cnte;
void add(int u, int v) {
  e[++cnte].to = v, e[cnte].next = head[u], head[u] = cnte;
}
int n, b[300003], dp[300003], cnt;
void dfs(int u, int last) {
  if (u != 1 && !e[head[u]].next) {
    dp[u] = 1;
    cnt++;
    return;
  }
  if (b[u]) dp[u] = 300003;
  for (int i = head[u]; i; i = e[i].next) {
    int v = e[i].to;
    if (v == last) continue;
    dfs(v, u);
    if (b[u])
      dp[u] = min(dp[u], dp[v]);
    else
      dp[u] += dp[v];
  }
}
int main() {
  scanf("%d", &n);
  for (int i = 1; i <= n; i++) scanf("%d", b + i);
  for (int i = 2; i <= n; i++) {
    int u;
    scanf("%d", &u);
    add(u, i), add(i, u);
  }
  dfs(1, 0);
  printf("%d\n", cnt - dp[1] + 1);
  return 0;
}
