#include <bits/stdc++.h>
using namespace std;
vector<int> child[300001];
int n;
int d[300001], t[300001];
int f(int u) {
  if (d[u] >= 0) return d[u];
  if (child[u].empty()) return 1;
  int ret = 0;
  if (t[u]) ret = (1 << 30);
  for (int i = 0; i < child[u].size(); i++) {
    int v = child[u][i];
    if (t[u] == 0)
      ret += f(v);
    else
      ret = min(ret, f(v));
  }
  return d[u] = ret;
}
int main() {
  scanf("%d", &n);
  for (int i = 1; i <= n; i++) scanf("%d", &t[i]);
  for (int i = 2; i <= n; i++) {
    int par;
    scanf("%d", &par);
    child[par].push_back(i);
  }
  memset(d, -1, sizeof(d));
  int cnt = 0;
  for (int i = 1; i <= n; i++) {
    if (child[i].empty()) cnt++;
  }
  printf("%d\n", cnt - f(1) + 1);
  return 0;
}
