#include <bits/stdc++.h>
using namespace std;
const int dr[] = {-1, 0, 1, 0, -1, -1, 1, 1};
const int dc[] = {0, -1, 0, 1, -1, 1, -1, 1};
const int N = 312345;
vector<int> son[N];
int n, cur, sym[N], k;
int dfs(int u) {
  if (son[u].empty()) return 1;
  if (sym[u] == 0) {
    int tot = 0;
    for (int v : son[u]) tot += dfs(v);
    return tot;
  } else {
    int minm = k;
    for (int v : son[u]) minm = min(minm, dfs(v));
    return minm;
  }
}
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(nullptr);
  cin >> n;
  for (int i = 1; i <= n; i++) cin >> sym[i];
  for (int i = 2; i <= n; i++) {
    int x;
    cin >> x;
    son[x].push_back(i);
  }
  k = 0;
  for (int i = 1; i <= n; i++) {
    if (son[i].empty()) ++k;
  }
  int val = dfs(1);
  cout << k - val + 1 << '\n';
  return 0;
}
