#include <bits/stdc++.h>
#pragma GCC optimize(2)
#pragma comment(linker, "/STACK:102400000,102400000")
using namespace std;
const long long mod = 998244353;
const long long INF = 1e9 + 7;
const int base = 131;
const double eps = 0.000001;
const double pi = 3.1415926;
int n, cnt, sum;
int m[300010], f[300010];
int head[300010], dp[300010], vis[300010];
struct edge {
  int to, nxt;
} e[300010];
void add(int u, int v) {
  e[cnt].to = v;
  e[cnt].nxt = head[u];
  head[u] = cnt++;
}
void dfs(int u) {
  dp[u] = 1;
  if (!vis[u]) {
    sum++;
    return;
  }
  int tmp = INF;
  if (!m[u]) tmp = 0;
  for (int i = head[u]; ~i; i = e[i].nxt) {
    int en = e[i].to;
    dfs(en);
    if (m[u])
      tmp = min(dp[en], tmp);
    else
      tmp += dp[en];
    dp[u] = tmp;
  }
}
int main() {
  while (~scanf("%d", &n)) {
    memset(head, -1, sizeof(head));
    ;
    memset(vis, 0, sizeof(vis));
    ;
    memset(dp, 0, sizeof(dp));
    ;
    sum = cnt = 0;
    for (int i = 1; i <= n; i++) {
      scanf("%d", &m[i]);
    }
    for (int i = 2; i <= n; i++) {
      scanf("%d", &f[i]);
      add(f[i], i);
      vis[f[i]] = 1;
    }
    dfs(1);
    printf("%d\n", sum - dp[1] + 1);
  }
}
