#include <bits/stdc++.h>
using namespace std;
int f[300005];
vector<int> v[300005];
int d[300005];
int numLeaf = 0;
void dfs(int a) {
  if (f[a] == 1)
    d[a] = 1000000000;
  else
    d[a] = 0;
  if (!v[a].size()) d[a] = 1, numLeaf++;
  for (auto i : v[a]) {
    dfs(i);
    if (f[a] == 1) {
      d[a] = min(d[a], d[i]);
    } else {
      d[a] += d[i];
    }
  }
}
int main() {
  ios::sync_with_stdio(0);
  cin.tie(NULL);
  int n;
  cin >> n;
  for (int i = 1; i <= n; i++) cin >> f[i];
  for (int i = 1; i <= n - 1; i++) {
    int x;
    cin >> x;
    v[x].push_back(i + 1);
  }
  dfs(1);
  cout << numLeaf + 1 - d[1] << endl;
  return 0;
}
