#include <bits/stdc++.h>
using namespace std;
const int maxn = 3e5 + 10;
const int INF = 0x3f3f3f3f;
vector<int> to[maxn];
int a[maxn];
int d[maxn];
int cnt = 0;
void dfs(int i) {
  if (!to[i].size()) {
    d[i] = 1;
    cnt++;
    return;
  }
  if (a[i] == 0)
    d[i] = 0;
  else
    d[i] = INF;
  for (int j = 0; j < to[i].size(); j++) {
    dfs(to[i][j]);
    if (a[i])
      d[i] = min(d[i], d[to[i][j]]);
    else
      d[i] += d[to[i][j]];
  }
}
int main() {
  int n, x;
  scanf("%d", &n);
  for (int i = 1; i <= n; i++) scanf("%d", a + i);
  for (int i = 2; i <= n; i++) {
    scanf("%d", &x);
    to[x].push_back(i);
  }
  dfs(1);
  printf("%d\n", cnt - d[1] + 1);
}
