#include <bits/stdc++.h>
using namespace std;
int n;
vector<vector<int>> g;
int main() {
  cin >> n;
  g.resize(n, vector<int>());
  vector<int> m(n);
  for (int i = 0; i < n; i++) {
    cin >> m[i];
  }
  for (int i = 1; i < n; i++) {
    int x;
    cin >> x;
    x--;
    g[x].push_back(i);
  }
  vector<int> dp(n);
  int cnt = 0;
  for (int i = n - 1; i >= 0; i--) {
    if (g[i].size() == 0) {
      cnt++;
      dp[i] = 1;
    } else {
      if (m[i]) {
        dp[i] = 1e9;
        for (auto j : g[i]) {
          dp[i] = min(dp[i], dp[j]);
        }
      } else {
        dp[i] = 0;
        for (auto j : g[i]) {
          dp[i] += dp[j];
        }
      }
    }
  }
  cout << cnt + 1 - dp[0];
  return 0;
}
