N = int(input()) S = list(map(int, input().split())) T = list(map(int, input().split())) s0, s1, s2 = S.count(0), S.count(1), S.count(2) t0, t1, t2 = T.count(0), T.count(1), T.count(2) if 2 in S: if 0 in S: print(s2*N+s1) else: if 2 in T: print((s2+t2)*N-s2*t2) else: print(s2*N+s1) elif 2 in T: if 0 in T: print(t2*N+t1) else: if 2 in S: print((s2+t2)*N-s2*t2) else: print(t2*N+t1) else: print(max(s1, t1))