N = int(input()) Ss = list(map(int, input().split())) Ts = list(map(int, input().split())) if 2 in Ss and 2 in Ts: s = Ss.count(2) t = Ts.count(2) print(s * N + t * N - s * t) elif 2 in Ss and 2 not in Ts: s = Ss.count(2) print(s * N + Ss.count(1)) elif 2 in Ss and 2 not in Ts: Ss, Ts = Ts, Ss s = Ss.count(2) print(s * N + Ss.count(1)) else: print(max(Ss.count(1), Ts.count(1)))