#include <bits/stdc++.h>
using namespace std;
struct edge {
  int t, nxt;
} e[600010];
int n, cnt, be[300010], mn_mx[300010], f, vid[300010], tot;
void add(const int& x, const int& y) {
  e[++cnt].t = y, e[cnt].nxt = be[x], be[x] = cnt;
}
void dfs(const int& x) {
  if (!be[x]) return (void)(++tot, vid[x] = 1);
  if (mn_mx[x]) {
    vid[x] = 1e9;
    for (int i = be[x]; i; i = e[i].nxt)
      dfs(e[i].t), vid[x] = min(vid[x], vid[e[i].t]);
  } else
    for (int i = be[x]; i; i = e[i].nxt) dfs(e[i].t), vid[x] += vid[e[i].t];
}
int main() {
  scanf("%d", &n);
  for (int i = 1; i <= n; ++i) scanf("%d", &mn_mx[i]);
  for (int i = 2; i <= n; ++i) scanf("%d", &f), add(f, i);
  dfs(1), printf("%d", tot - vid[1] + 1);
  return 0;
}
