#include <bits/stdc++.h>
using namespace std;
int a[300005];
bool vis[300005];
int n, m;
vector<int> e[300005];
int son[300005];
void dfs(int x) {
  if (e[x].size() == 0)
    son[x] = 1;
  else
    son[x] = vis[x] ? n : 0;
  for (int i = 0; i < e[x].size(); i++) {
    int v = e[x][i];
    dfs(v);
    if (vis[x])
      son[x] = min(son[x], son[v]);
    else
      son[x] += son[v];
  }
  return;
}
int main() {
  scanf("%d", &n);
  for (int i = 1; i <= n; i++) scanf("%d", &vis[i]);
  for (int i = 2, x; i <= n; i++) {
    scanf("%d", &x);
    e[x].push_back(i);
  }
  int cnt = 0;
  for (int i = 1; i <= n; i++) {
    if (e[i].size() == 0) cnt++;
  }
  dfs(1);
  printf("%d\n", cnt - son[1] + 1);
  return 0;
}
