#include <bits/stdc++.h>
using namespace std;
const int N = 3e5 + 5;
const int inf = 0x3f3f3f3f;
int n, a[N], sz[N], k;
vector<int> G[N];
void dfs(int u) {
  int tmp = 0;
  if (G[u].size() == 0) k++, sz[u] = 1;
  for (int i = 0; i < G[u].size(); i++) {
    int v = G[u][i];
    dfs(v);
    tmp += sz[v];
    if (a[u])
      sz[u] = min(sz[u], sz[v]);
    else
      sz[u] = max(sz[u], tmp);
  }
}
int main() {
  scanf("%d", &n);
  for (int i = 1; i <= n; i++) {
    scanf("%d", &a[i]);
    if (a[i])
      sz[i] = inf;
    else
      sz[i] = -inf;
  }
  for (int i = 2, x; i <= n; i++) scanf("%d", &x), G[x].push_back(i);
  dfs(1);
  cout << k - sz[1] + 1;
}
