#include <bits/stdc++.h>
using namespace std;
class GRAPH {
 public:
  int to[1000000], next[1000000];
  int head[500000];
  int cnt;
  GRAPH() { cnt = 1; }
  void add(int x, int y) {
    next[cnt] = head[x];
    to[cnt] = y;
    head[x] = cnt++;
  }
};
GRAPH g;
int n;
int flag[500000];
int cnt;
void init() {
  int x;
  cin >> n;
  for (register int i = 1; i < n + 1; i++) scanf("%d", &flag[i]);
  for (register int i = 2; i < n + 1; i++) {
    cin >> x;
    g.add(x, i);
  }
}
int dfs(int pos) {
  int tem;
  if (flag[pos] == 1) {
    tem = 0x3f3f3f3f;
    for (register int i = g.head[pos]; i; i = g.next[i])
      tem = min(tem, dfs(g.to[i]));
    if (tem == 0x3f3f3f3f) {
      cnt++;
      tem = 1;
    }
  } else {
    tem = 0;
    for (register int i = g.head[pos]; i; i = g.next[i]) tem += dfs(g.to[i]);
    if (tem == 0) {
      cnt++;
      tem = 1;
    }
  }
  return tem;
}
int main() {
  init();
  cnt += 1 - dfs(1);
  cout << cnt;
  return ~~(0 ^ 0 ^ 0);
}
