#include <bits/stdc++.h>
using namespace std;
const int maxn = 3e5 + 50, INF = 0x3f3f3f3f;
inline int read() {
  register int x = 0, w = 1;
  register char ch = getchar();
  for (; ch < '0' || ch > '9'; ch = getchar())
    if (ch == '-') w = -1;
  for (; ch >= '0' && ch <= '9'; ch = getchar()) x = x * 10 + ch - '0';
  return x * w;
}
int n, k, ans, a[maxn], deg[maxn];
struct Edge {
  int to, next;
} e[maxn << 1];
int tot, head[maxn];
inline void Add(register int u, register int v) {
  e[++tot].to = v;
  e[tot].next = head[u];
  head[u] = tot;
}
int size[maxn];
inline void DFS(register int u, register int fa) {
  if (!deg[u]) return size[u] = 1, k++, void();
  size[u] = a[u] ? INF : 0;
  for (register int i = head[u]; i; i = e[i].next) {
    register int v = e[i].to;
    DFS(v, u);
    if (a[u])
      size[u] = min(size[u], size[v]);
    else
      size[u] += size[v];
  }
}
int main() {
  n = read();
  for (register int i = 1; i <= n; i++) a[i] = read();
  for (register int i = 2, fa; i <= n; i++) fa = read(), Add(fa, i), deg[fa]++;
  DFS(1, 0), printf("%d\n", k - size[1] + 1);
  return 0;
}
