#include using namespace std; #define ALL(x) x.begin(),x.end() #define rep(i,n) for(int i=0;i<(n);i++) #define debug(v) cout<<#v<<":";for(auto x:v){cout<bool chmax(T &a,const T &b){if(abool chmin(T &a,const T &b){if(b ostream &operator<<(ostream &os,const pair&p){ os< ostream &operator<<(ostream &os,const vector&v){ for(int i=0;i<(int)v.size();i++) os< istream &operator>>(istream &is,pair&p){ is>>p.first>>p.second; return is; } template istream &operator>>(istream &is,vector&v){ for(T &x:v)is>>x; return is; } signed main(){ int n;cin>>n; int a[n][n]; rep(i,n)rep(j,n)a[i][j]=-1; int h=0,w=0; rep(i,n){ int s;cin>>s; if(s==0){ rep(j,n)a[i][j]=0; }else if(s==1){ h++; }else{ rep(j,n)a[i][j]=1; } } rep(j,n){ int t;cin>>t; if(t==0){ rep(i,n)a[i][j]=0; }else if(t==1){ w++; }else{ rep(i,n)a[i][j]=1; } } h=0,w=0;// matigaeta rep(i,n){ bool f=false; rep(j,n){ if(a[i][j]==-1)f=true; } h+=f; } rep(j,n){ bool f=false; rep(i,n){ if(a[i][j]==-1)f=true; } w+=f; } int res=0; rep(i,n)rep(j,n)if(a[i][j]==1)res++; res+=min(h,w); cout<