#include <bits/stdc++.h>
using namespace std;
const int N = 300100;
int n, op[N], tot, head[N], ver[N], nex[N], sz;
inline void add(int x, int y) {
  ver[++tot] = y;
  nex[tot] = head[x];
  head[x] = tot;
}
int d[N];
void dfs(int x) {
  if (!head[x]) d[x] = 1, sz++;
  for (register int i = head[x]; i; i = nex[i]) {
    dfs(ver[i]);
    if (op[x] == 0) {
      d[x] += d[ver[i]];
    } else {
      if (!d[x])
        d[x] = d[ver[i]];
      else
        d[x] = min(d[x], d[ver[i]]);
    }
  }
}
int main() {
  scanf("%d", &n);
  for (register int i = 1; i <= n; i++) scanf("%d", &op[i]);
  for (register int f, i = 2; i <= n; i++) scanf("%d", &f), add(f, i);
  dfs(1);
  printf("%d", sz + 1 - d[1]);
  return 0;
}
