/** * @FileName a.cpp * @Author kanpurin * @Created 2020.09.11 21:42:15 **/ #include "bits/stdc++.h" using namespace std; typedef long long ll; int main() { int n;cin >> n; vector s(n),t(n); int s_0 = 0; int s_2 = 0; int t_0 = 0; int t_2 = 0; for (int i = 0; i < n; i++) { cin >> s[i]; if (s[i] == 0) s_0++; else if (s[i] == 2) s_2++; } for (int i = 0; i < n; i++) { cin >> t[i]; if (t[i] == 0) t_0++; else if (t[i] == 2) t_2++; } if (s_0 > 0 && s_2 > 0) { cout << s_2 * n + n - (s_2 + s_0) << endl; } else if (t_0 > 0 && t_2 > 0) { cout << t_2 * n + n - (t_2 + t_0) << endl; } else if (s_2 > 0 && t_2 > 0) { cout << (s_2 + t_2) * (n - 1) << endl; } else if (s_0 > 0) { cout << n - min(s_0,t_0) << endl; } else if (s_2 > 0) { cout << s_2 * n + n - s_2 << endl; } else if (t_0 > 0) { cout << n - min(s_0,t_0) << endl; } else if (t_2 > 0) { cout << t_2 * n + n - t_2 << endl; } else { cout << n << endl; } return 0; }