#include <bits/stdc++.h>
using namespace std;
int tz;
int n, a;
int mm[300300];
int dp[300300], cnt[300300];
vector<int> child[300300];
void dfs(int cur) {
  if (((int)child[cur].size()) == 0) {
    dp[cur] = 1;
    cnt[cur] = 1;
    return;
  }
  for (auto cc : child[cur]) {
    dfs(cc);
    cnt[cur] += cnt[cc];
  }
  if (mm[cur] == 1) {
    int sml = 1000000000;
    for (auto cc : child[cur]) sml = min(sml, cnt[cc] - dp[cc]);
    dp[cur] = cnt[cur] - sml;
  } else {
    int loss = 0;
    for (auto cc : child[cur]) loss += cnt[cc] - dp[cc];
    dp[cur] = cnt[cur] - loss - ((int)child[cur].size()) + 1;
  }
}
int main() {
  cin >> n;
  for (int i = (1); i <= (n); ++i) cin >> mm[i];
  for (int i = (2); i <= (n); ++i) {
    cin >> a;
    child[a].push_back(i);
  }
  dfs(1);
  cout << dp[1] << endl;
}
