#include <bits/stdc++.h>
using namespace std;
int n, m, a, b, op[1001000], l = 1, r, val[1001000];
vector<int> adj[1001000];
int dfs(int no) {
  if (adj[no].size() == 0)
    val[no] = 1;
  else if (op[no] == 0) {
    for (int v : adj[no]) val[no] += dfs(v);
  } else {
    val[no] = INT_MAX;
    for (int v : adj[no]) val[no] = min(val[no], dfs(v));
  }
  return val[no];
}
int solve(int node, int maxi) {
  if (adj[node].size() == 0) {
    if (maxi)
      return r--;
    else
      return l++;
  }
  int ans;
  if (op[node] == 0) {
    ans = INT_MAX;
    for (int v : adj[node]) ans = min(ans, solve(v, maxi));
  } else {
    int jon = -1;
    for (int v : adj[node])
      if (jon == -1 || val[v] < val[jon]) jon = v;
    ans = solve(jon, maxi);
    for (int v : adj[node])
      if (v != jon) solve(v, 0);
  }
  return ans;
}
int main() {
  scanf("%d", &n);
  for (int i = 1; i <= n; i++) {
    scanf("%d", &op[i]);
  }
  for (int i = 2; i <= n; i++) {
    scanf("%d", &b);
    adj[b].push_back(i);
  }
  for (int i = 1; i <= n; i++)
    if (adj[i].size() == 0) r++;
  dfs(1);
  printf("%d\n", solve(1, 1));
  return 0;
}
