#include <bits/stdc++.h>
using namespace std;
const int maxn = 3e5 + 10;
int a[maxn];
int f[maxn];
vector<int> vt[maxn];
int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  int n = 0;
  cin >> n;
  for (int i = 0; i < n; i++) cin >> a[i];
  for (int i = 1; i < n; i++) {
    int p;
    cin >> p;
    p--;
    vt[p].push_back(i);
  }
  int leaveCnt = 0;
  for (int i = n - 1; i >= 0; i--) {
    if (vt[i].size() == 0) {
      leaveCnt++;
      f[i] = 1;
    } else {
      int tmp = (a[i]) ? 1e6 : 0;
      for (int v : vt[i]) {
        assert(v > i);
        if (a[i]) {
          tmp = min(tmp, f[v]);
        } else {
          tmp += f[v];
        }
      }
      f[i] = tmp;
    }
  }
  cout << leaveCnt - f[0] + 1;
  return 0;
}
