#include <bits/stdc++.h>
using namespace std;
int main() {
  int(n);
  scanf("%d", &n);
  vector<int> ps(n);
  vector<int> mm(n);
  for (int i = 0; i < (n); ++i) {
    scanf("%d", &(mm[i]));
  }
  vector<int> nbc(n, 0);
  vector<vector<int> > cs(n, vector<int>(0));
  for (int i = 0; i < (n - 1); ++i) {
    int(x);
    scanf("%d", &x);
    x--;
    ps[i + 1] = x;
    nbc[x]++;
    cs[x].push_back(i + 1);
  }
  vector<int> enfantstraites(n, 0);
  queue<int> tt;
  for (int i = 0; i < (n); ++i) {
    if (!nbc[i]) tt.push(i);
  }
  vector<int> nbeqc(n, 0);
  int nbl = 0;
  while (!tt.empty()) {
    int p = tt.front();
    tt.pop();
    if (nbc[p]) {
      int toteqc = 0;
      int mineqc = 10000000;
      for (auto c : cs[p]) {
        toteqc += nbeqc[c];
        mineqc = min(mineqc, nbeqc[c]);
      }
      nbeqc[p] = mm[p] ? (mineqc) : (toteqc);
    } else {
      nbeqc[p] = 1;
      nbl++;
    }
    if (p) {
      enfantstraites[ps[p]]++;
      if (enfantstraites[ps[p]] == nbc[ps[p]]) {
        tt.push(ps[p]);
      }
    }
  }
  printf("%d\n", nbl + 1 - nbeqc[0]);
}
