#include <bits/stdc++.h>
using namespace std;
template <typename T>
inline void read(T& x) {
  x = 0;
  int f = 1;
  char c = getchar();
  while (c < '0' || c > '9') {
    if (c == '-') f = -1;
    c = getchar();
  }
  while (c >= '0' && c <= '9') {
    x = x * 10 + c - '0';
    c = getchar();
  }
  x *= f;
}
const int N = 3e5 + 5;
int val[N];
vector<int> G[N];
int sz[N];
int ans = 0;
void dfs(int u) {
  if (G[u].size() == 0) {
    sz[u] = 1;
    ans++;
    return;
  }
  int tmp = 0;
  for (int i = 0; i < G[u].size(); i++) {
    int v = G[u][i];
    dfs(v);
    tmp += sz[v];
    if (val[u] == 1) {
      sz[u] = min(sz[u], sz[v]);
    } else {
      sz[u] = max(sz[u], tmp);
    }
  }
}
int main() {
  int n;
  cin >> n;
  for (int i = 1; i <= n; i++) {
    read(val[i]);
    if (val[i] == 1)
      sz[i] = 1e9;
    else
      sz[i] = 0;
  }
  for (int i = 2; i <= n; i++) {
    int u;
    read(u);
    G[u].push_back(i);
  }
  dfs(1);
  printf("%d\n", ans - sz[1] + 1);
}
