#include <bits/stdc++.h>
using namespace std;
const int mx = 3e5 + 10;
int n, ty[mx], out[mx], siz;
int cnt[mx];
vector<int> g[mx];
void dfs(int u) {
  cnt[u] = 1e9;
  int sum = 0;
  for (int v : g[u]) {
    dfs(v);
    if (ty[u]) cnt[u] = min(cnt[v], cnt[u]);
    sum += cnt[v];
  }
  if (!ty[u]) cnt[u] = sum;
  if (!out[u]) cnt[u] = 1;
}
int main() {
  scanf("%d", &n);
  for (int i = 1; i <= n; i++) scanf("%d", ty + i);
  int v;
  for (int i = 2; i <= n; i++) {
    scanf("%d", &v);
    g[v].push_back(i);
    out[v]++;
  }
  for (int i = 1; i <= n; i++)
    if (!out[i]) siz++;
  dfs(1);
  printf("%d\n", siz - cnt[1] + 1);
  return 0;
}
