#include <bits/stdc++.h>
using namespace std;
const int N = 3e5 + 5;
const int INF = 0x3f3f3f3f;
const double EPS = 1e-7;
const double PI = acos(-1);
const long long MOD = 1e9 + 7;
vector<int> G[N];
int op[N];
int cnt;
int dfs(int pos) {
  int sz = G[pos].size();
  if (sz == 0) {
    cnt++;
    return 1;
  }
  int ret;
  if (op[pos] == 0) {
    ret = 0;
    for (int i = (0); i <= (sz - 1); i++) {
      ret += dfs(G[pos][i]);
    }
  } else {
    ret = 0x3f3f3f3f;
    for (int i = (0); i <= (sz - 1); i++) {
      ret = min(ret, dfs(G[pos][i]));
    }
  }
  return ret;
}
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++) {
    int x;
    scanf("%d", &x);
    G[x].push_back(i);
  }
  int tmp = dfs(1);
  printf("%d\n", cnt - tmp + 1);
  return 0;
}
