O(N) Python Solution
\ncount_a = defaultdict(int)\ncount_b = defaultdict(int)\nN = len(A)\nsame = 0\n\nfor i in range(N):\n\tcount_a[A[i]] += 1\n\tcount_b[B[i]] += 1\n\n\tif A[i] ==
```\ncount_a = defaultdict(int)\ncount_b = defaultdict(int)\nN = len(A)\nsame = 0\n\nfor i in range(N):\n\tcount_a[A[i]] += 1\n\tcount_b[B[i]] += 1\n\n\tif A[i] == B[i]:\n\t\tsame += 1\n\nfor x in range(1,7):\n\tif (count_a[x] + count_b[x] - same) == N:\n\t\treturn N - max(count_a[x], count_b[x])\n\nreturn -1\n```
['Python']