#include <bits/stdc++.h>
using namespace std;
const int MAXN = 3e5 + 10;
int op[MAXN];
int fa[MAXN];
int dp[MAXN];
int leaf = 0;
vector<int> son[MAXN];
void dfs(int x) {
  int cnt = son[x].size();
  int mn = 0, mx = -1;
  for (int i = 0; i < cnt; ++i) {
    dfs(son[x][i]);
    if (mx == -1)
      mx = dp[son[x][i]];
    else
      mx = min(mx, dp[son[x][i]]);
    mn += dp[son[x][i]];
  }
  if (cnt == 0) {
    leaf++;
    dp[x] = 1;
    return;
  }
  if (op[x] == 1) {
    dp[x] = mx;
  } else {
    dp[x] = mn;
  }
}
int main() {
  int n;
  scanf("%d", &n);
  for (int i = 1; i <= n; ++i) {
    scanf("%d", &op[i]);
  }
  for (int i = 2; i <= n; ++i) {
    scanf("%d", &fa[i]);
    son[fa[i]].push_back(i);
  }
  dfs(1);
  printf("%d\n", leaf - dp[1] + 1);
  return 0;
}
