#include <bits/stdc++.h>
using namespace std;
inline long long isqrt(long long k) {
  long long r = sqrt(k) + 1;
  while (r * r > k) r--;
  return r;
}
inline long long icbrt(long long k) {
  long long r = cbrt(k) + 1;
  while (r * r * r > k) r--;
  return r;
}
inline long long minize(long long& a, long long b) {
  return a = (a > b ? b : a);
}
inline long long maxize(long long& a, long long b) {
  return a = (a < b ? b : a);
}
inline string toString(long long n) {
  stringstream ss;
  ss << n;
  return ss.str();
}
double const eps = 1e-6;
long long const Base = 1e9 + 7, oo = 1e17, MAXN = 1e6;
long long A[MAXN + 5], C[MAXN + 5], lev;
vector<long long> dske[MAXN + 5];
bitset<MAXN + 5> bi;
pair<long long, long long> go(long long x) {
  bi[x] = 1;
  long long v = (C[x] ? oo : 0), sum = 0, flag = 0;
  for (long long i = 0; i < dske[x].size(); i++) {
    if (bi[dske[x][i]]) continue;
    flag = 1;
    pair<long long, long long> xx = go(dske[x][i]);
    if (C[x])
      minize(v, xx.first);
    else
      v += xx.first;
    sum += xx.second;
  }
  if (!flag) {
    lev++;
    return make_pair(1, 1);
  }
  return make_pair(v, sum);
}
long long Solves() {
  long long n, m, k, cnt = 0, ans = 0, x, y, q, c, sum = 0, v, t;
  cin >> n;
  for (long long i = 1; i <= n; i++) cin >> C[i];
  for (long long i = 2; i <= n; i++) {
    cin >> x;
    dske[x].push_back(i);
  }
  ans = go(1).first;
  assert(ans >= 1 and ans <= lev);
  cout << (lev - ans + 1) << endl;
  return 0;
}
int main() {
  long long JUDGE_ONLINE = 1;
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  long long test = 1;
  for (long long T = 1; T <= test; T++) {
    Solves();
  }
  if (!JUDGE_ONLINE)
    cout << "\nTime elapsed: " << 1000 * clock() / CLOCKS_PER_SEC << "ms\n";
}
