import sys input=sys.stdin.readline def I(): return int(input()) def MI(): return map(int, input().split()) def LI(): return list(map(int, input().split())) def main(): mod=10**9+7 N=I() S=LI() T=LI() s2=S.count(2) t2=T.count(2) ans=s2*N + t2*N - (s2*t2) s1=S.count(1) t1=T.count(1) if s2!=0: t1=0 if t2!=0: s1=0 ans+=max(s1,t1) print(ans) main()