from collections import Counter N = int(input()) A = list(map(int, input().split())) B = list(map(int, input().split())) ca = Counter(A) cb = Counter(B) ans = N * (ca[2] + cb[2]) - ca[2] * cb[2] if ca[2] % 2 == 1: cb[0], cb[1] = cb[1], cb[0] if cb[2] % 2 == 1: ca[0], ca[1] = ca[1], ca[0] while ca[1] and cb[1]: ans += 1 ca[1] -= 1 cb[1] -= 1 cnt = min(ca[1], cb[1]) ans += cnt ans += ca[1] - cnt ans += cb[1] - cnt print(ans)