#include <bits/stdc++.h>
using namespace std;
vector<int> v[300005];
int sig[300005];
int dp[300005];
int ans;
int main() {
  int n;
  scanf("%d", &n);
  for (int i = 1; i <= n; i++) scanf("%d", &sig[i]);
  for (int i = 2; i <= n; i++) {
    int f;
    scanf("%d", &f);
    v[f].push_back(i);
  }
  int sum = 0;
  for (int i = n; i >= 1; i--) {
    if (v[i].size() == 0) {
      sum++;
      dp[i] = 1;
    } else {
      if (sig[i]) {
        dp[i] = 1e9;
        for (int j = 0; j < v[i].size(); j++) dp[i] = min(dp[i], dp[v[i][j]]);
      } else {
        dp[i] = 0;
        for (int j = 0; j < v[i].size(); j++) dp[i] += dp[v[i][j]];
      }
    }
  }
  printf("%d\n", sum - dp[1] + 1);
  return 0;
}
