n=int(input()) s=list(map(int,input().split())) t=list(map(int,input().split())) stwo=s.count(2) ttwo=t.count(2) sone=s.count(1) tone=t.count(1) if(stwo>0 and ttwo>0): print((stwo+ttwo)*n-stwo*ttwo) elif(stwo>0): print(n*stwo+sone) elif(ttwo>0): print(n*ttwo+tone) else: print(max(sone,tone))