#include <bits/stdc++.h>
using namespace std;
const int N = 1e6 + 7;
int a[N], cal[N], tot;
vector<int> g[N];
void dfs(int u, int pp = -1) {
  if (g[u].size() == 1) {
    tot++;
    cal[u] = 1;
    return;
  }
  if (a[u]) cal[u] = 1e8;
  for (int v : g[u]) {
    if (v == pp) continue;
    dfs(v, u);
    if (a[u])
      cal[u] = min(cal[u], cal[v]);
    else
      cal[u] += cal[v];
  }
}
int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  int T, cs = 0;
  int n;
  cin >> n;
  for (int i = 1; i <= n; i++) {
    cin >> a[i];
  }
  for (int i = 2; i <= n; i++) {
    int v;
    cin >> v;
    g[v].push_back(i);
    g[i].push_back(v);
  }
  dfs(1);
  cout << tot - cal[1] + 1 << '\n';
  return 0;
}
