#include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include using namespace std; using ll = long long; using P = pair; constexpr int INF = 1001001001; // constexpr int mod = 1000000007; constexpr int mod = 998244353; template inline bool chmax(T& x, T y){ if(x < y){ x = y; return true; } return false; } template inline bool chmin(T& x, T y){ if(x > y){ x = y; return true; } return false; } int main(){ ios::sync_with_stdio(false); cin.tie(nullptr); int n; cin >> n; vector s(n), t(n); vector> a(n, vector(n)); vector fs(n), ft(n); set ones, onet; for(int i = 0; i < n; ++i){ cin >> s[i]; if(s[i] == 2){ for(int j = 0; j < n; ++j){ a[i][j] = 1; ft[j] = true; } } } for(int j = 0; j < n; ++j){ cin >> t[j]; if(t[j] == 2){ for(int i = 0; i < n; ++i){ a[i][j] = 1; fs[i] = true; } } } for(int i = 0; i < n; ++i){ if(s[i] == 0 || s[i] == 2 || fs[i]) continue; ones.emplace(i); } for(int j = 0; j < n; ++j){ if(t[j] == 0 || t[j] == 2 || ft[j]) continue; onet.emplace(j); } int ans = 0; for(int i = 0; i < n; ++i){ for(int j = 0; j < n; ++j){ ans += a[i][j]; } } ans += max(ones.size(), onet.size()); cout << ans << endl; return 0; }