#include <bits/stdc++.h>
using namespace std;
int n, f[300005], x, sum = 0;
vector<int> root[300005];
int dfs(int pos) {
  if (root[pos].size() == 0) {
    sum++;
    return 1;
  }
  if (f[pos]) {
    int ans = 0x3f3f3f3f;
    for (auto i : root[pos]) ans = min(ans, dfs(i));
    return ans;
  } else {
    int ans = 0;
    for (auto i : root[pos]) ans += dfs(i);
    return ans;
  }
}
int main() {
  cin >> n;
  for (int i = 1; i <= n; i++) scanf("%d", &f[i]);
  for (int i = 2; i <= n; i++) {
    scanf("%d", &x);
    root[x].push_back(i);
  }
  int ans = dfs(1);
  ans = sum + 1 - ans;
  cout << ans;
  return 0;
}
