#include <bits/stdc++.h>
inline int read() {
  int x = 0, f = 1;
  char ch = getchar();
  while (!isdigit(ch)) {
    if (ch == '-') f = -1;
    ch = getchar();
  }
  while (isdigit(ch)) {
    x = (x << 1) + (x << 3) + ch - '0';
    ch = getchar();
  }
  return x * f;
}
const int N = 3e5 + 10;
int n, a[N], dp[N], num, head[N], cnt, son[N];
struct Edge {
  int v, next;
} e[N << 1];
inline void add(int u, int v) {
  e[++cnt].v = v;
  e[cnt].next = head[u];
  head[u] = cnt;
}
inline void dfs(int u) {
  if (u > 1 && !son[u]) {
    dp[u] = 1;
    ++num;
    return;
  }
  if (a[u])
    dp[u] = 0x3f3f3f3f;
  else
    dp[u] = 0;
  for (int i = head[u]; i; i = e[i].next) {
    int v = e[i].v;
    dfs(v);
    if (a[u])
      dp[u] = std::min(dp[u], dp[v]);
    else
      dp[u] += dp[v];
  }
}
int main() {
  n = read();
  for (int i = 1; i <= n; i++) a[i] = read();
  for (int i = 2; i <= n; i++) {
    int u = read();
    add(u, i);
    son[u]++;
  }
  dfs(1);
  printf("%d\n", num + 1 - dp[1]);
  return 0;
}
