#include <bits/stdc++.h>
using namespace std;
const int N = 3e5 + 15;
int n, a[N], pa[N], leaf;
vector<int> g[N];
int dfs(int pos) {
  if (!((int)(g[pos]).size())) return 0;
  if (a[pos]) {
    int res = N;
    for (int i : g[pos]) res = min(res, dfs(i));
    return res;
  } else {
    int res = 0;
    for (int i : g[pos]) res += dfs(i);
    return res + ((int)(g[pos]).size()) - 1;
  }
}
int main() {
  ios::sync_with_stdio(false);
  cin >> n;
  for (int i = 0; i < n; i++) cin >> a[i];
  for (int i = 1; i < n; i++) {
    cin >> pa[i];
    pa[i]--;
    g[pa[i]].push_back(i);
  }
  for (int i = 0; i < n; i++)
    if (!g[i].size()) a[i] = 1, leaf++;
  cout << leaf - dfs(0) << endl;
}
