#include <bits/stdc++.h>
using namespace std;
const int N = 3e5 + 50, INF = 0, MOD = 0;
int n, h[N], mdl[N], mark[N];
vector<int> adj[N];
int DFSS(int v, int p) {
  if (adj[v].empty()) return 1;
  if (mdl[v] != 1) {
    int cnt = 0;
    for (auto u : adj[v]) {
      cnt += DFSS(u, v);
    }
    return cnt;
  }
  int cnt = N;
  for (auto u : adj[v]) {
    cnt = min(cnt, DFSS(u, v));
  }
  return cnt;
}
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  cin >> n;
  for (int i = 1; i <= n; i++) cin >> mdl[i];
  for (int i = 2; i <= n; i++) {
    int x;
    cin >> x;
    adj[x].push_back(i);
  }
  int K = 0;
  for (int i = 1; i <= n; i++)
    if (adj[i].empty()) K++;
  int cnt = DFSS(1, 0);
  if (cnt == 0) cnt++;
  cout << K - cnt + 1;
  return 0;
}
