#include <bits/stdc++.h>
using namespace std;
int k = 0;
int n;
int dfs(int v, vector<pair<bool, vector<int>>> &tree) {
  if (tree[v].second.empty()) {
    ++k;
    return 0;
  } else {
    vector<int> anss;
    for (auto s : tree[v].second) {
      anss.push_back(dfs(s, tree));
    }
    if (tree[v].first) {
      int res = n;
      for (auto el : anss) {
        if (el < res) {
          res = el;
        }
      }
      return res;
    } else {
      int res = 0;
      for (auto el : anss) {
        res += el;
      }
      return res + anss.size() - 1;
    }
  }
}
int main() {
  cin >> n;
  vector<pair<bool, vector<int>>> tree(n);
  for (int i = 0; i < n; ++i) {
    int cur;
    cin >> cur;
    tree[i].first = cur == 1;
  }
  for (int i = 1; i < n; ++i) {
    int cur;
    cin >> cur;
    tree[cur - 1].second.push_back(i);
  }
  int loss = dfs(0, tree);
  cout << k - loss << endl;
  return 0;
}
