#include <bits/stdc++.h>
using namespace std;
const int MAXN = 3 * 100100, INF = 0x3f3f3f3f;
int n, o[MAXN], p[MAXN], leaf;
vector<int> c[MAXN];
int dfs(int v) {
  if (c[v].size() == 0) return 1;
  int k = (o[v] ? INF : 0);
  for (const int& u : c[v]) k = (o[v] ? min(k, dfs(u)) : k + dfs(u));
  return k;
}
int main() {
  scanf("%d", &n);
  for (int i = 1; i <= n; ++i) scanf("%d", &o[i]);
  for (int i = 2; i <= n; ++i) scanf("%d", &p[i]), c[p[i]].push_back(i);
  for (int i = 1; i <= n; ++i) leaf += (!c[i].size());
  printf("%d\n", leaf - dfs(1) + 1);
}
