#include <bits/stdc++.h>
using namespace std;
const int N = 3e5 + 5;
vector<int> G[N];
int f[N];
int val[N];
bool vis[N];
int k = 0;
int dfs(int u) {
  if (G[u].size() == 0) {
    k++;
    return 1;
  }
  if (f[u] == 1) {
    int x = 0x3f3f3f3f;
    for (auto &v : G[u]) x = min(x, dfs(v));
    return x;
  }
  if (f[u] == 0) {
    int x = 0;
    for (auto &v : G[u]) x += dfs(v);
    return x;
  }
  return 0;
}
int main() {
  int n;
  scanf("%d", &n);
  for (int i = 1; i <= n; i++) {
    scanf("%d", &f[i]);
  }
  for (int i = 2; i <= n; i++) {
    int fa;
    scanf("%d", &fa);
    G[fa].push_back(i);
  }
  int root = 1;
  int ret = dfs(root);
  printf("%d\n", k - ret + 1);
  return 0;
}
