#include <bits/stdc++.h>
using namespace std;
vector<int> G[300005];
int a[300005], Sz[300005], n, v, lt;
void dfs(int u, int fa) {
  int son = 0;
  for (auto v : G[u]) {
    if (fa == v) continue;
    son++;
    dfs(v, u);
    Sz[u] += Sz[v];
  }
  if (son == 0) {
    lt++;
    Sz[u] = 1;
    return;
  }
  if (a[u] == 1) {
    Sz[u] = n;
    for (auto v : G[u]) {
      if (fa == v) continue;
      Sz[u] = min(Sz[v], Sz[u]);
    }
  }
}
int main() {
  cin >> n;
  for (int i = 1; i <= n; i++) scanf("%d", &a[i]);
  for (int u = 2; u <= n; u++) {
    scanf("%d", &v);
    G[u].push_back(v);
    G[v].push_back(u);
  }
  dfs(1, 0);
  cout << lt - Sz[1] + 1;
}
