#include <bits/stdc++.h>
using namespace std;
const int MAXN = 3e5 + 5;
int n, k;
vector<int> op(MAXN);
int search(const vector<vector<int>>& edges, int u) {
  if (edges[u].empty()) {
    return 1;
  }
  if (op[u] == 0) {
    int sum = 0;
    for (auto v : edges[u]) {
      sum += search(edges, v);
    }
    return sum;
  }
  int minVal = 1e9;
  for (auto v : edges[u]) {
    minVal = min(minVal, search(edges, v));
  }
  return minVal;
}
int main() {
  ios::sync_with_stdio(false);
  while (cin >> n) {
    for (int i = 1; i <= n; ++i) {
      cin >> op[i];
    }
    vector<vector<int>> edges(n + 1);
    for (int i = 2, p; i <= n; ++i) {
      cin >> p;
      edges[p].push_back(i);
    }
    k = 0;
    for (int i = 1; i <= n; ++i) {
      if (edges[i].empty()) {
        ++k;
      }
    }
    cout << k - search(edges, 1) + 1 << endl;
  }
  return 0;
}
