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] ans += max(ca[1], cb[1]) print(ans)