#include <bits/stdc++.h>
using namespace std;
long long getM(const vector<long long>& V) {
  long long k = 0;
  for (long long i = 1; i < V.size(); i++)
    if (V[i] > V[k]) k = i;
  return k;
}
long long ERT(long long v, long long n, const vector<long long>& oper,
              const vector<long long>& parent,
              const vector<vector<long long> >& children,
              vector<long long>& osszeg) {
  if (children[v].size() == 0) {
    osszeg[v] = 1;
    return 1;
  }
  if (osszeg[v] != -1) return osszeg[v];
  if (oper[v] == 0) {
    osszeg[v] = 0;
    for (long long i = 0; i < children[v].size(); i++) {
      osszeg[v] += ERT(children[v][i], n, oper, parent, children, osszeg);
    }
  } else {
    for (long long i = 0; i < children[v].size(); i++) {
      long long s = ERT(children[v][i], n, oper, parent, children, osszeg);
      if (osszeg[v] == -1 || s < osszeg[v]) osszeg[v] = s;
    }
  }
  return osszeg[v];
}
int main() {
  long long n;
  cin >> n;
  vector<long long> oper(n);
  vector<long long> parent(n - 1);
  for (long long i = 0; i < n; i++) cin >> oper[i];
  vector<vector<long long> > children(n);
  for (long long i = 0; i < n - 1; i++) {
    cin >> parent[i];
    parent[i]--;
    children[parent[i]].push_back(i + 1);
  }
  long long k = 0;
  for (long long i = 0; i < n; i++) {
    if (children[i].size() == 0) k++;
  }
  vector<long long> osszeg(n, -1);
  long long e = ERT(0, n, oper, parent, children, osszeg);
  cout << k - e + 1 << endl;
}
