#include <bits/stdc++.h>
using namespace std;
int T[300200];
vector<int> ad[300200];
int d[300200];
int dfs(int sr, int p) {
  int sum = 0, mn = 1e9, x = 0;
  if (p && d[sr] == 1) return 1;
  for (auto o : ad[sr]) {
    if (o == p) continue;
    x = dfs(o, sr);
    sum += x;
    mn = min(mn, x);
  }
  if (T[sr] == 1)
    return mn;
  else
    return sum;
}
int main() {
  int n, m;
  cin >> n;
  for (int i = 1; i <= n; i++) {
    cin >> T[i];
  }
  for (int i = 2; i <= n; i++) {
    int second;
    cin >> second;
    ad[i].push_back(second);
    ad[second].push_back(i);
    d[i]++;
    d[second]++;
  }
  int L = 0;
  for (int i = 2; i <= n; i++)
    if (d[i] == 1) L++;
  int x = dfs(1, 0);
  cout << (L + 1 - x) << endl;
}
