using System; using static System.Console; using System.Linq; using System.Collections.Generic; class Program { static int NN => int.Parse(ReadLine()); static int[] NList => ReadLine().Split().Select(int.Parse).ToArray(); static int[][] NArr(long n) => Enumerable.Repeat(0, (int)n).Select(_ => NList).ToArray(); public static void Main() { Solve(); } static void Solve() { var n = NN; var s = NList; var t = NList; var s2c = s.Count(c => c == 2); var t2c = t.Count(c => c == 2); if (s2c > 0 && t2c > 0) { WriteLine(s2c * n + t2c * n - s2c * t2c); } else if (s2c > 0) { var s1c = s.Count(c => c == 1); WriteLine(s2c * n + s1c); } else if (t2c > 0) { var t1c = t.Count(c => c == 1); WriteLine(t2c * n + t1c); } else { var s1c = s.Count(c => c == 1); var t1c = t.Count(c => c == 1); WriteLine(Math.Max(s1c, t1c)); } } static long GCD(long a, long b) { if (a < b) return GCD(b, a); if (a % b == 0) return b; return GCD(b, a % b); } }