#include <bits/stdc++.h>
using namespace std;
long long int n;
vector<long long int> v[300009];
bool ismax[300009];
pair<long long int, long long int> p[300009];
void dfs(long long int ver = 1) {
  if (v[ver].size() == 0) {
    p[ver].first = 1;
    p[ver].second = 1;
    return;
  }
  p[ver].second = 0;
  for (long long int i = 0; i < v[ver].size(); i++) {
    dfs(v[ver][i]);
    p[ver].second += p[v[ver][i]].second;
  }
  if (ismax[ver] == 1) {
    p[ver].first = 0;
    long long int mini = INT_MAX;
    ;
    for (auto i : v[ver]) {
      p[ver].first += p[i].second;
      mini = min(p[i].second - p[i].first, mini);
    }
    p[ver].first -= mini;
  } else {
    p[ver].first = 0;
    for (auto i : v[ver]) {
      p[ver].first += (p[i].first - 1);
    }
    p[ver].first++;
  }
}
signed main() {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
  cin >> n;
  for (long long int i = 1; i <= n; i++) {
    cin >> ismax[i];
  }
  for (long long int i = 2; i <= n; i++) {
    long long int a;
    cin >> a;
    v[a].push_back(i);
  }
  dfs();
  cout << p[1].first << "\n";
}
