#include <bits/stdc++.h>
using namespace std;
const int INF = 1e9;
const long long LINF = 1e18;
const double PI = acos(-1);
const int MAXN = 300005;
int n, v, OP[MAXN], leaves = 0;
vector<vector<int>> G;
bool visited[MAXN];
int dfs(int v) {
  visited[v] = true;
  if (G[v].empty()) {
    leaves++;
    return 1;
  }
  if (OP[v] == 1) {
    int maxv = dfs(G[v][0]);
    for (int i = 1; i < ((int)(G[v]).size()); i++) {
      maxv = min(maxv, dfs(G[v][i]));
    }
    return maxv;
  } else {
    int val = 0;
    for (int i = 0; i < ((int)(G[v]).size()); i++) {
      val += dfs(G[v][i]);
    }
    return val;
  }
}
int main() {
  scanf("%d", &n);
  G.resize(n);
  for (int i = 0; i < n; i++) {
    scanf("%d", &OP[i]);
  }
  for (int i = 1; i < n; i++) {
    scanf("%d", &v);
    G[v - 1].push_back(i);
  }
  int ans = dfs(0);
  printf("%d\n", leaves - ans + 1);
  return 0;
}
