import sys input = sys.stdin.readline N=int(input()) S=list(map(int,input().split())) T=list(map(int,input().split())) ANS=[[-1]*N for i in range(N)] for i in range(N): if S[i]==0: for j in range(N): ANS[i][j]=0 elif S[i]==2: for j in range(N): ANS[i][j]=1 if T[i]==0: for j in range(N): ANS[j][i]=0 elif T[i]==2: for j in range(N): ANS[j][i]=1 score=0 R=[0]*N C=[0]*N for i in range(N): for j in range(N): if ANS[i][j]==1: score+=1 R[i]=-1 C[j]=-1 elif ANS[i][j]==-1: if R[i]!=-1: R[i]=1 C[j]=1 print(score+max(R.count(1),C.count(1)))