import sys def I(): return int(sys.stdin.readline().rstrip()) def LI(): return list(map(int,sys.stdin.readline().rstrip().split())) #空白あり N = I() S = LI() T = LI() s0,s1,s2 = 0,0,0 t0,t1,t2 = 0,0,0 for s in S: if s == 0: s0 += 1 elif s == 1: s1 += 1 else: s2 += 1 for t in T: if t == 0: t0 += 1 elif t == 1: t1 += 1 else: t2 += 1 if s2 > 0 and t2 > 0: print(N*(s2+t2)-s2*t2) elif s2 > 0: print(s1+N*s2) elif t2 > 0: print(t1+N*t2) else: print(max(s1,t1))