#include <bits/stdc++.h>
using namespace std;
const long long N = 3e5 + 10;
long long tipo[N];
vector<long long> adj[N];
long long val[N];
long long hojas;
long long dfs(long long u) {
  bool ok = true;
  if (tipo[u] == 0) {
    val[u] = 0;
  } else {
    val[u] = 1e18;
  }
  for (long long v : adj[u]) {
    dfs(v);
    ok = false;
    if (tipo[u] == 0) {
      val[u] += val[v];
    } else {
      val[u] = min(val[v], val[u]);
    }
  }
  if (ok) {
    hojas++;
    val[u] = 1;
  }
  return val[u];
}
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  cout.precision(10);
  cout << fixed;
  long long n, x;
  cin >> n;
  for (long long i = 1; i <= n; i++) {
    cin >> tipo[i];
  }
  for (long long i = 2; i <= n; i++) {
    cin >> x;
    adj[x].push_back(i);
  }
  long long aux = dfs(1);
  cout << hojas - dfs(1) + 1 << endl;
  return 0;
}
