#include <bits/stdc++.h>
using namespace std;
const int maxn = 100000 + 5;
int a[maxn], p[maxn], lenToR[maxn], n, t1[maxn], t2[maxn];
int getLen(int node) {
  if (lenToR[node]) return lenToR[node];
  if (node == 1)
    return 0;
  else
    return lenToR[node] = getLen(p[node]) + 1;
}
int main() {
  scanf("%d", &n);
  for (int i = 1; i <= n; i++) {
    scanf("%d", a + i);
  }
  for (int i = 2; i <= n; i++) {
    scanf("%d", p + i);
  }
  p[1] = 1;
  for (int i = 1; i <= n; i++) {
    getLen(i);
  }
  int maxNodeParity = 0;
  for (int i = 1; i <= n; i++) {
    if (lenToR[i] > maxNodeParity) maxNodeParity = lenToR[i];
  }
  maxNodeParity %= 2;
  int len1 = 0, len2 = 0, parity = 0;
  for (int i = 1; i <= n; i++) {
    if (lenToR[i] % 2 == maxNodeParity) {
      t1[++len1] = a[i];
      parity ^= a[i];
    } else {
      t2[++len2] = a[i];
    }
  }
  long long cnt = 0;
  if (parity == 0) {
    cnt = (long long)len1 * (len1 - 1) / 2 + (long long)len2 * (len2 - 1) / 2;
  }
  for (int i = 1; i <= len1; i++) {
    int temp = t1[i] ^ parity;
    for (int j = 1; j <= len2; j++) {
      if ((temp ^ t2[j]) == 0) {
        cnt++;
      }
    }
  }
  cout << cnt << endl;
  return 0;
}
