#include <bits/stdc++.h>
using namespace std;
const int N = 3e5 + 10, inf = 0x3f3f3f3f;
vector<int> g[N];
int n, dp[N], f[N];
int dfs(int x) {
  if (g[x].size() == 0) return 1;
  if (dp[x]) return dp[x];
  if (f[x]) {
    int max1 = inf;
    for (int i = 0; i < g[x].size(); i++) max1 = min(max1, dfs(g[x][i]));
    dp[x] = max1;
  } else {
    int min1 = 0;
    for (int i = 0; i < g[x].size(); i++) min1 += dfs(g[x][i]);
    dp[x] = min1;
  }
  return dp[x];
}
int main() {
  scanf("%d", &n);
  for (int i = 1; i <= n; i++) scanf("%d", &f[i]);
  for (int i = 2; i <= n; i++) {
    int u;
    scanf("%d", &u);
    g[u].push_back(i);
  }
  int leaf = 0;
  for (int i = 1; i <= n; i++) {
    if (g[i].size() == 0) leaf++;
  }
  printf("%d\n", leaf - dfs(1) + 1);
  return 0;
}
