#include <bits/stdc++.h>
using namespace std;
const int maxn = 3e5 + 5;
const int inf = 1e9 + 7;
int n, k = 0;
int kc[maxn], a[maxn];
vector<int> g[maxn];
void dfs(int u) {
  if ((int)g[u].size() == 0) {
    ++k;
    kc[u] = -1;
    return;
  }
  if (a[u]) kc[u] = -inf;
  for (auto &v : g[u]) {
    dfs(v);
    if (!a[u])
      kc[u] += kc[v];
    else
      kc[u] = max(kc[u], kc[v]);
  }
}
void solve() {
  cin >> n;
  for (int i = 1; i <= n; ++i) cin >> a[i];
  for (int i = 2; i <= n; ++i) {
    int u;
    cin >> u;
    g[u].push_back(i);
  }
  dfs(1);
  cout << k + kc[1] + 1;
}
int main() { solve(); }
