#include <bits/stdc++.h>
using namespace std;
const int maxn = 3e5 + 7;
const int INF = 0x3f3f3f3f;
int n, tag[maxn], k, dp[maxn];
vector<int> son[maxn];
void get_leaves() {
  for (auto i = 1; i <= n; i++)
    if (son[i].empty()) k++;
}
void build_tree() {
  for (auto i = 2; i <= n; i++) {
    int parent;
    scanf("%d", &parent);
    son[parent].push_back(i);
  }
  get_leaves();
}
int dfs(int curnode) {
  if (son[curnode].empty()) return dp[curnode] = 1;
  if (tag[curnode] == 1)
    dp[curnode] = INF;
  else
    dp[curnode] = 0;
  for (auto i = 0; i < (int)son[curnode].size(); i++) {
    int nxt = son[curnode][i];
    if (tag[curnode] == 1)
      dp[curnode] = min(dp[curnode], dfs(nxt));
    else
      dp[curnode] += dfs(nxt);
  }
  return dp[curnode];
}
int main() {
  scanf("%d", &n);
  for (auto i = 1; i <= n; i++) scanf("%d", &tag[i]);
  build_tree();
  printf("%d\n", k + 1 - dfs(1));
  return 0;
}
