#include <bits/stdc++.h>
using namespace std;
const int INF = 0x3f3f3f3f;
const int NIL = -1;
template <class T>
inline T mx(T a, T b) {
  return a > b ? a : b;
}
template <class T>
inline T mi(T a, T b) {
  return a < b ? a : b;
}
template <class T>
inline void sw(T &a, T &b) {
  T t = a;
  a = b;
  b = t;
}
template <class T>
inline T mabs(T x) {
  return x < 0 ? -x : x;
}
inline char gc() {
  char ret;
  while ((ret = getchar()) == ' ' || ret == '\n' || ret == '\t')
    ;
  return ret;
}
struct _IO {
  char ch;
  _IO &operator>>(int &x) {
    x = 0;
    while ((ch = getchar()) < '0' || ch > '9')
      ;
    while (ch >= '0' && ch <= '9') x = x * 10 + ch - '0', ch = getchar();
    return *this;
  }
} IO;
const int LIM = 3e5 + 10;
vector<int> adj[LIM];
int dp[LIM], tp[LIM], k;
void dfs(int crt) {
  vector<int> &t = adj[crt];
  if (!t.size()) {
    k++, dp[crt] = 1;
    return;
  }
  int ret = !tp[crt] ? 0 : INF;
  for (int i = 0; i < t.size(); i++) {
    dfs(t[i]);
    if (tp[crt])
      ret = mi(ret, dp[t[i]]);
    else
      ret += dp[t[i]];
  }
  dp[crt] = ret;
}
int main() {
  int n, x;
  IO >> n;
  for (int i = 1; i <= n; i++) IO >> tp[i];
  for (int i = 2; i <= n; i++) IO >> x, adj[x].push_back(i);
  dfs(1);
  printf("%d", k - dp[1] + 1);
  return 0;
}
