import java.util.HashSet;
import java.util.LinkedList;
import java.util.Queue;
import java.util.Scanner;
public class Main {
public static void main
(String[] args
) {
Scanner scanner
= new Scanner
(System.
in); int n = scanner.nextInt();
HashSet
<Integer
>[] G
= new HashSet[n
];
for(int i = 0; i < n; i++) {
G[i] = new HashSet<Integer>();
}
int[] from = new int[n];
int[] to = new int[n];
for(int i = 0; i < n - 1; i++) {
from[i] = scanner.nextInt();
}
for(int i = 0; i < n - 1; i++) {
to[i] = scanner.nextInt();
}
for(int i = 0; i < n - 1; i++) {
int u = from[i];
int v = to[i];
G[u].add(v);
G[v].add(u);
}
int[] val = new int[n];
for(int i = 0; i < n; i++) {
val[i] = scanner.nextInt();
}
Queue<Integer> queue = new LinkedList<>();
int destroyedNodes = 0;
for(int i = 0; i < n; i++) {
if(G[i].size() == 1 && val[i] == 0) {
queue.offer(i);
}
}
while(!queue.isEmpty()) {
int leafToDestroy = queue.poll();
int neighborOfLeafToDestroy = G[leafToDestroy].iterator().next();
G[neighborOfLeafToDestroy].remove(leafToDestroy);
destroyedNodes++;
if(G[neighborOfLeafToDestroy].size() == 1 && val[neighborOfLeafToDestroy] == 0) {
queue.offer(neighborOfLeafToDestroy);
}
}
System.
out.
println((n
- destroyedNodes
) << 1); }
}