#include <bits/stdc++.h>
using namespace std;
vector<vector<long long> > a(300500);
vector<long long> what(300500, false), subtree(300500), used(300500, 0),
    cnt(300500, 0), used2(300500, 0);
long long n;
long long leaf = 0;
void dfs(long long start) {
  used[start] = 1;
  if (a[start].size() == 1) {
    leaf++;
    subtree[start] = 1;
    return;
  }
  long long rez = 0;
  for (long long i = 0; i < a[start].size(); i++) {
    long long next = a[start][i];
    if (!used[next]) dfs(next);
    rez += subtree[next];
  }
  subtree[start] = rez;
}
void solve(long long start) {
  used2[start] = true;
  if (a[start].size() == 1) {
    cnt[start] = 1;
    return;
  }
  long long rez = 0, best = 10000000;
  ;
  for (long long i = 0; i < a[start].size(); i++) {
    long long next = a[start][i];
    if (next > start) {
      solve(next);
      best = min(best, cnt[next]);
      rez += cnt[next];
    }
  }
  if (!what[start])
    cnt[start] = rez;
  else
    cnt[start] = best;
}
int main() {
  cin >> n;
  long long i, j;
  for (i = 1; i <= n; i++) cin >> what[i];
  for (i = 2; i <= n; i++) {
    long long p;
    cin >> p;
    a[p].push_back(i);
    a[i].push_back(p);
  }
  dfs(1);
  solve(1);
  cout << leaf + 1 - cnt[1];
  return 0;
}
