#include #include #include #include #include #include #include #include #include #include using namespace std; long long gcd(long long a,long long b){ long long x=max(a,b),y=min(a,b); if(x%y==0)return y; else return gcd(y,x%y); } long long lcm(long long a,long long b){ return (a/gcd(a,b))*b; } int main(){ cin.tie(0); ios::sync_with_stdio(false); //cout << fixed << setprecision(1) << endl; int n; cin >> n; vector s(n); vector t(n); for(int i = 0; i < n; i++)cin >> s[i]; for(int i = 0; i < n; i++)cin >> t[i]; vector> ans(n,vector(n,0)); int cnt = 0; //s for(int i = 0; i < n; i++){ if(s[i] == 0){ continue; }else if(s[i] == 2){ for(int j = 0; j < n; j++){ ans[i][j] = 1; } }else if(s[i] == 1){ ans[i][0] = 1; } } //t for(int i = 0; i < n; i++){ if(t[i] == 0){ for(int j = 0; j < n; j++){ ans[j][i] = 0; } }else if(s[i] == 2){ for(int j = 0; j < n;j++){ ans[i][j] = 1; } }else if(s[i] == 1){ bool ok = false; for(int j = 0; j < n; j++){ if(ans[j][i] == 1){ ok = true; break; } } if(!ok){ cnt += 1; } } } //cnt for(int i = 0; i < n; i++){ for(int j = 0; j < n; j++){ if(ans[i][j] == 1)cnt++; } } cout << cnt << endl; return 0; }