#include <bits/stdc++.h>
using namespace std;
const char el = '\n';
int tree[300001];
bool m[300001];
bool isleaf[300001];
int dp[300001];
vector<vector<int>> children{};
int numleaves = 0;
void computesize(int node) {
  int acc = 0;
  for (int child : children[node]) {
    computesize(child);
    acc += tree[child];
  }
  tree[node] = acc + 1;
  if (tree[node] == 1) {
    isleaf[node] = true;
    ++numleaves;
  }
  return;
}
void computedp(int node) {
  if (isleaf[node]) {
    dp[node] = 1;
    return;
  }
  int minrk = 300000;
  int sumrk = 0;
  for (int child : children[node]) {
    computedp(child);
    sumrk += dp[child];
    minrk = min(minrk, dp[child]);
  }
  if (m[node]) {
    dp[node] = minrk;
  } else {
    dp[node] = sumrk;
  }
}
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
  int n;
  cin >> n;
  children.resize(n + 1);
  for (int i = 1; i <= n; ++i) {
    cin >> m[i];
  }
  int parent;
  for (int i = 2; i <= n; ++i) {
    cin >> parent;
    children[parent].push_back(i);
  }
  computesize(1);
  computedp(1);
  cout << numleaves - dp[1] + 1 << el;
}
