#include <bits/stdc++.h>
using namespace std;
inline int read() {
  int re = 0, flag = 1;
  char ch = getchar();
  while (!isdigit(ch)) {
    if (ch == '-') flag = -1;
    ch = getchar();
  }
  while (isdigit(ch)) re = (re << 1) + (re << 3) + ch - '0', ch = getchar();
  return re * flag;
}
int n, first[300010], cnte = -1;
struct edge {
  int to, next;
} a[600010];
inline void add(int u, int v) {
  a[++cnte] = (edge){v, first[u]};
  first[u] = cnte;
  a[++cnte] = (edge){u, first[v]};
  first[v] = cnte;
}
int dp[300010], w[300010], le[300010];
void dfs(int u, int f) {
  int i, v;
  if (!le[u]) {
    dp[u] = 1;
    return;
  }
  if (w[u] == 0)
    dp[u] = 0;
  else
    dp[u] = 1e9;
  for (i = first[u]; ~i; i = a[i].next) {
    v = a[i].to;
    if (v == f) continue;
    dfs(v, u);
    if (w[u] == 0)
      dp[u] += dp[v];
    else
      dp[u] = min(dp[u], dp[v]);
  }
}
int main() {
  n = read();
  int i, t1, t2, cnt = 0;
  memset(first, -1, sizeof(first));
  for (i = 1; i <= n; i++) w[i] = read();
  for (i = 2; i <= n; i++) t1 = read(), add(i, t1), le[t1] = 1;
  for (i = 1; i <= n; i++) cnt += !le[i];
  dfs(1, 0);
  cout << cnt - dp[1] + 1 << '\n';
}
