N = int(input()) S = list(map(int, input().split())) T = list(map(int, input().split())) s = S.count(2) t = T.count(2) ans = (s + t) * N - s * t ans += max(sum([(i + t) % 2 if i != 2 else 0 for i in S]), sum([(i + s) % 2 if i != 2 else 0 for i in T])) print(ans)