#include using namespace std; using ll = int; using ull = unsigned long long int; using ld = long double; constexpr ll MAX = 0; constexpr ld PI = 3.14159265358979; constexpr ll MOD = 0;//2024948111; ld dotorad(ld K){return PI * K / 180.0;} ld radtodo(ld K){return K * 180.0 / PI;} mt19937 mt; void randinit(){srand((unsigned)time(NULL));mt = mt19937(rand());} int main(){ ll N; cin >> N; vector A(N),B(N); for(ll i = 0;i < N;i++) cin >> A[i]; for(ll i = 0;i < N;i++) cin >> B[i]; ll ans = 0; for(ll i = 0;i < N;i++){ ll s = 0,x = 0,b = 0; for(ll j = 0;j < 64 && i + j < N;j++){ s += A[i + j]; x ^= A[i + j]; b ^= B[i + j]; if(s - x == b) ans++; } } cout << ans << endl; }