#include <bits/stdc++.h>
using namespace std;
const int mn = 3e5 + 5;
const int mod = 1e9 + 7;
int n;
int a[mn];
int f[mn];
vector<int> g[mn];
int leaves;
int d[mn];
void dp(int x) {
  if (((int)g[x].size()) == 0) d[x] = 1, leaves++;
  if (((int)g[x].size()) && a[x] == 1) d[x] = 1e9;
  for (auto &i : g[x]) {
    dp(i);
    if (a[x] == 1)
      d[x] = min(d[x], d[i]);
    else {
      d[x] += d[i];
    }
  }
}
int main() {
  scanf("%d", &n);
  for (int i = 1; i <= n; i++) scanf("%d", &a[i]);
  for (int i = 2; i <= n; i++) {
    scanf("%d", &f[i]);
    g[f[i]].push_back(i);
  }
  dp(1);
  printf("%d\n", leaves + 1 - d[1]);
  return 0;
}
