#include <bits/stdc++.h>
using namespace std;
int N, v[300005], X, d[300005], K;
vector<int> Tree[300005];
void DFS(int node) {
  if (!Tree[node].size())
    d[node] = 1, K++;
  else {
    if (v[node]) d[node] = 2140000000;
    for (int i = 0; i < Tree[node].size(); i++) {
      DFS(Tree[node][i]);
      if (v[node])
        d[node] = min(d[node], d[Tree[node][i]]);
      else
        d[node] += d[Tree[node][i]];
    }
  }
}
int main() {
  scanf("%d", &N);
  for (int i = 1; i <= N; i++) scanf("%d", &v[i]);
  for (int i = 2; i <= N; i++) {
    scanf("%d", &X);
    Tree[X].push_back(i);
  }
  DFS(1);
  printf("%d", K - d[1] + 1);
  return 0;
}
