#include <bits/stdc++.h>
using namespace std;
const int maxn = 3e5 + 3;
const int maxm = 1e6 + 3;
const int mod = 1e9 + 7;
const int oo = 1e9 + 5;
const long double pi = 3.141592653589793238462643383279502884;
void input() {
  if (fopen("abc"
            ".inp",
            "r")) {
    freopen(
        "abc"
        ".inp",
        "r", stdin);
    freopen(
        "abc"
        ".out",
        "w", stdout);
  }
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
}
int n;
int t[maxn], p[maxn], f[maxn], leaf[maxn];
vector<int> g[maxn];
void dfs(int u) {
  if (g[u].empty()) {
    f[u] = 1;
    leaf[u] = 1;
    return;
  }
  for (int v : g[u]) {
    dfs(v);
    leaf[u] += leaf[v];
  }
  if (t[u]) {
    int _min = oo;
    for (int v : g[u]) _min = min(_min, leaf[v] - f[v]);
    f[u] = leaf[u] - _min;
  } else {
    int sum = 0;
    for (int v : g[u]) sum += f[v] - 1;
    f[u] = sum + 1;
  }
}
int main() {
  input();
  cin >> n;
  for (int i = 1; i <= n; ++i) cin >> t[i];
  for (int i = 2; i <= n; ++i) {
    cin >> p[i];
    g[p[i]].push_back(i);
  }
  dfs(1);
  cout << f[1];
  return 0;
}
