N = int(input()) A = list(map(int, input().split())) B = list(map(int, input().split())) ans = 0 for i in range(N): if B[i] == 1: continue tot = 0 xor = 0 j = i while (tot + A[j]) - (xor ^ A[j]) == 0 and j >= 0: ans += 1 tot += A[j] xor ^= A[j] j -= 1 print(ans)