#include <bits/stdc++.h>
using namespace std;
vector<bool> is_max;
vector<vector<int> > child;
int leaf_count = 0;
int DFS(int a) {
  if (child[a].empty()) {
    leaf_count++;
    return 0;
  }
  if (is_max[a]) {
    int ans = 1e9;
    for (int b : child[a]) ans = min(ans, DFS(b));
    return ans;
  }
  int ans = (int)child[a].size() - 1;
  for (int b : child[a]) ans += DFS(b);
  return ans;
}
int main() {
  cin.tie(NULL);
  cout.tie(NULL);
  ios_base::sync_with_stdio(false);
  int n;
  cin >> n;
  child.resize(n);
  is_max.resize(n);
  for (int i = 0; i < n; i++) {
    int a;
    cin >> a;
    is_max[i] = (a == 1);
  }
  for (int i = 1; i < n; i++) {
    int a;
    cin >> a;
    a--;
    child[a].push_back(i);
  }
  int ans_i = DFS(0);
  cout << leaf_count - ans_i << endl;
}
