#include <bits/stdc++.h>
using namespace std;
const int N = 300010;
int n, d[N], k = 0;
int flag[N];
int fa[N];
vector<int> e[N];
void dfs(int u) {
  if (e[u].size() == 0) {
    ++k, d[u] = 1;
    return;
  }
  if (flag[u]) d[u] = n + n;
  for (auto v : e[u]) {
    dfs(v);
    if (flag[u])
      d[u] = min(d[v], d[u]);
    else
      d[u] += d[v];
  }
}
int main() {
  scanf("%d", &n);
  for (int i = 1; i <= n; i++) scanf("%d", &flag[i]);
  for (int i = 2; i <= n; i++) scanf("%d", &fa[i]), e[fa[i]].push_back(i);
  dfs(1), printf("%d\n", k - d[1] + 1);
  return 0;
}
