n=int(input()) s=list(map(int,input().split())) t=list(map(int,input().split())) a=[[None]*n for _ in range(n)] row1,col1=False,False cnt_row,cnt_col=0,0 ans=0 for i,x in enumerate(s): if x==0: for j in range(n): a[i][j]=0 elif x==2: for j in range(n): a[i][j]=1 row1=True else: cnt_row+=1 for i,x in enumerate(t): if x==0: for j in range(n): a[j][i]=0 elif x==2: for j in range(n): a[j][i]=1 col1=True else: cnt_col+=1 for y in a: for x in y: if x is not None:ans+=x if col1: ans+=cnt_col elif row1: ans+=cnt_row else: ans+=min(cnt_row,cnt_col) print(ans)