#include <bits/stdc++.h>
using namespace std;
template <typename Tp>
inline void outarr(Tp _begin, Tp _end, const char* _delim = " ") {
  for (Tp current = _begin; current != _end; ++current) {
    std::cout << *current << _delim;
  }
  std::cout << '\n';
}
using ll = long long;
using pii = std::pair<int, int>;
constexpr int INF = 0x3f3f3f3f;
constexpr int MOD = static_cast<const int>(1e9 + 7);
constexpr int MAXN = 300000;
int op[MAXN];
vector<int> gr[MAXN];
int CNT_CHILDREN = 0;
int Dfs(int from = 0) {
  if (gr[from].empty()) {
    ++CNT_CHILDREN;
    return 0;
  }
  int res;
  if (op[from] == 1) {
    res = -INF;
    for (int to : gr[from]) {
      res = max(res, Dfs(to));
    }
  } else {
    res = 1;
    for (int to : gr[from]) {
      res += Dfs(to) - 1;
    }
  }
  return res;
}
int main() {
  std::ios_base::sync_with_stdio(false);
  std::cin.tie(nullptr);
  int n;
  cin >> n;
  for (int i = 0; i < (n); ++i) {
    cin >> op[i];
  }
  for (int i = 1; i < n; ++i) {
    int p;
    cin >> p;
    gr[p - 1].push_back(i);
  }
  cout << CNT_CHILDREN + Dfs() << "\n";
  return 0;
}
