#include <bits/stdc++.h>
using namespace std;
const int maxn = (int)3e5 + 50;
int n, type[maxn], f[maxn], k;
vector<int> a[maxn];
void DFS(int u) {
  if (a[u].size() == 0) {
    ++k;
    f[u] = 1;
    return;
  }
  if (type[u] == 1) {
    f[u] = n;
    for (int v : a[u]) {
      DFS(v);
      f[u] = min(f[u], f[v]);
    }
  } else {
    f[u] = 0;
    for (int v : a[u]) {
      DFS(v);
      f[u] += f[v];
    }
  }
}
int main() {
  cin >> n;
  for (int i = 1; i <= n; ++i) cin >> type[i];
  for (int i = 2; i <= n; ++i) {
    int pa;
    cin >> pa;
    a[pa].push_back(i);
  }
  DFS(1);
  cout << k - f[1] + 1;
}
