N = int(input()) S = list(map(int, input().split())) T = list(map(int, input().split())) s2 = S.count(2) t2 = T.count(2) cnt = 0 if not s2: cnt = max(cnt, T.count(1)) if not t2: cnt = max(cnt, S.count(1)) print((s2 + t2) * N - s2 * t2 + cnt)