f=int(input())
a=input()
a=[int(i) for i in a.split()]
b=input()
b=[int(i) for i in b.split()]
c=[0,0,0,0,0,0]
cp = [0,0,0,0,0,0]
ans=[]
for i in a:
   c[i]+=1
for i in b:
   cp[i]+=1
t=1

for i in range(len(c)):
     if (cp[i]+c[i])%2==1:
          print(-1)
          t=0
          break
     else:
        ans.append(c[i] - (cp[i]+c[i])//2)
if t==1:
   pos , neg ,su= 0,0,0,
   for i in range(len(ans)):
      if ans[i]>0:
         pos+=ans[i]
      if ans[i]<0:
         neg+=ans[i]
      su+=ans[i]
   if su<0:print(-neg)
   if su==0:print(pos)
   if su>0:print(pos)

if __name__ == '__main__':
    n = input()
    a = map(int, raw_input().split(' '))
    b = map(int, raw_input().split(' '))

    a_vis = [0, 0, 0, 0, 0, 0]
    b_vis = [0, 0, 0, 0, 0, 0]

    for i in range(n):
        a_vis[a[i]] = a_vis[a[i]] + 1
        b_vis[b[i]] = b_vis[b[i]] + 1

    ans = 0
    for i in range(6):
        if (a_vis[i] + b_vis[i]) % 2:
            ans = -1
            break
        else:
            x = a_vis[i] -(a_vis[i] + b_vis[i]) / 2
            if x < 0:
                x = 0
            ans = ans + x

    print ans

import sys

n = int(sys.stdin.readline())
a = {1 : 0, 2 : 0, 3 : 0, 4 : 0, 5 : 0}
b = {1 : 0, 2 : 0, 3 : 0, 4 : 0, 5 : 0}
szamok = [int(x) for x in sys.stdin.readline().split()]
for elem in szamok :
	a[elem] += 1
szamok = [int(x) for x in sys.stdin.readline().split()]
for elem in szamok :
   	b[elem] += 1
counter = 0
for i in range(1, 6) :
	if (a[i] + b[i]) % 2 == 0 :
		if a[i] > b[i] :
			counter += (a[i] - b[i]) / 2
	else :
		sys.stdout.write("-1\n")
		sys.exit()
sys.stdout.write(str(counter) + "\n")

import sys
from collections import Counter

input()
a = Counter(map(int, raw_input().split()))
b = Counter(map(int, raw_input().split()))
counter = 0
for i in range(1, 6) :
	if (a[i] + b[i]) % 2 == 0 :
		if a[i] > b[i] :
			counter += (a[i] - b[i]) / 2
	else :
		print -1
		sys.exit()
print counter

import sys

n = int(raw_input())
A = map(int, raw_input().split(' '))
B = map(int, raw_input().split(' '))
s = [0] * 5
a = [0] * 5
b = [0] * 5
for i in range(n):
	if A[i] <= 5:
		s[A[i] - 1] += 1
		a[A[i] - 1] += 1
	if B[i] <= 5:
		s[B[i] - 1] += 1
		b[B[i] - 1] += 1
flag = 1

diff = 0
for i in range(5):
	if s[i] % 2 != 0:
		flag = 0
		print(-1)
		break
	diff += abs(a[i] - b[i])
if flag:
	print(diff / 4)

n=int(input())
arra=list(map(int,input().split()))
arrb=list(map(int,input().split()))
b=0
for i in range(1,6):
    if (arra.count(i)+arrb.count(i))%2!=0:
        b=1
        print(-1)
        break
#print(arra,arrb)
if b==0:
    used=[]
    count=0
    for i in range(n):
        if (arra[i]) not in arrb:
           used.append(arra[i])
        else:
           arrb.remove(arra[i])
    #print(arra,arrb)
    print(len(used)//2)

def fail():
    print(-1)
    exit()
read = lambda: map(int, input().split())
n = int(input())
a = sorted(read())
b = sorted(read())
for i in range(1, 6):
    if (a.count(i) + b.count(i)) % 2:
        fail()
cnt = 0
while 1:
    flag = False
    for i in range(n):
        if a.count(a[i]) > b.count(a[i]):
            for j in range(n):
                if a.count(b[j]) < b.count(b[j]) and a[i] != b[j]:
                    a[i], b[j] = b[j], a[i]
                    cnt += 1
                    break
            if flag: break
        if flag:
            break
    if not flag:
        break
print(cnt)

n = int(input())
a = [int(x) for x in input().split()]
b = [int(x) for x in input().split()]
s = set(a + b)
ab = a + b
for i in s:
    if ab.count(i) % 2 != 0:
        print(-1)
        exit(0)

for i in a:
    if i in b:
        b.remove(i)

print(len(b) // 2)

n = int(input())
A = list(map(int, input().split()))
B = list(map(int, input().split()))
cnt = [0] * 5
for elem in A:
    cnt[elem - 1] += 1
for elem in B:
    cnt[elem - 1] += 1
bad = 0
for elem in cnt:
    bad += elem % 2
if bad != 0:
    print(-1)
else:
    cntA = [0] * 5
    cntB = [0] * 5
    for elem in A:
        cntA[elem - 1] += 1
    for elem in B:
        cntB[elem - 1] += 1
    ans = 0
    for i in range(5):
        ans += abs(cntA[i] - cntB[i]) // 2
    print(ans // 2)

from collections import Counter
n = int(input())
a = Counter(list(map(int, input().split())))
b = Counter(list(map(int, input().split())))
possible = True
for i in range(1, 6):
  if (a[i] + b[i]) % 2:
    possible = False
    break

if not possible:
  print(-1)
else:
  ans = 0
  for i in range(1, 6):
    tot = (a[i] + b[i])//2
    if a[i] < tot:
      ans += tot - a[i]
  print(ans)

n = int(input())
a = list(map(int, input().split()))
b = list(map(int, input().split()))
A = [a.count(i) for i in range(1, 6)]
B = [b.count(i) for i in range(1, 6)]
cnt = 0
for j in range(5):
    if (A[j] + B[j]) % 2 != 0:
        print(-1)
        exit()
    cnt += abs(A[j] - B[j])
print(cnt // 4)

# 19:39
# Перераспределение учеников. Вход - оценки. Выход - количество перемещений
n = int(input())
class_A = [int(x) for x in input().split(' ')]
class_B = [int(x) for x in input().split(' ')]
cnt = [0 for x in range(1, 6)]

def main():
	for mark in class_A:
		cnt[mark - 1] += 1
	for mark in class_B:
		cnt[mark - 1] -= 1
	for mark in cnt:
		if mark % 2 != 0:
			return -1
	c = 0
	for mark in cnt:
		c += abs(mark)
	return c // 4

print(main())

##n = int(input())
##a = list(map(int, input().split()))
##print(' '.join(map(str, res)))

n = int(input())
a = list(map(int, input().split()))
b = list(map(int, input().split()))

ha = [0 for i in range(5)]
hb = [0 for i in range(5)]
for i in range(n):
    ha[a[i]-1] += 1
    hb[b[i]-1] += 1

res = 0
for i in range(5):
    if abs(ha[i]-hb[i])%2 != 0 and ha[i] != hb[i]:
        print('-1')
        exit(0)
    res += abs(ha[i]-hb[i])
res = res//2
res = res//2
print(res)

""" Created by Henrikh Kantuni on 2/26/17 """

if __name__ == "__main__":
    n = int(input())
    al = [int(x) for x in input().split()]
    bl = [int(x) for x in input().split()]
    a = {
        1: al.count(1),
        2: al.count(2),
        3: al.count(3),
        4: al.count(4),
        5: al.count(5),
    }
    b = {
        1: bl.count(1),
        2: bl.count(2),
        3: bl.count(3),
        4: bl.count(4),
        5: bl.count(5),
    }

    possible = True
    for key in a.keys():
        if (a[key] + b[key]) % 2 != 0:
            possible = False
            break

    if possible:
        swaps = 0
        for key in a.keys():
            if a[key] > b[key]:
                swaps += (a[key] - b[key]) // 2
        print(swaps)
    else:
        print(-1)

#   In this template you are not required to write code in main

import sys
inf = float("inf")

#sys.setrecursionlimit(1000000)
#from cmath import sqrt
#from collections import deque, Counter, OrderedDict,defaultdict
#from heapq import nsmallest, nlargest, heapify,heappop ,heappush, heapreplace
from math import ceil,floor,log,sqrt,factorial,pow,pi,gcd
#from bisect import bisect_left,bisect_right
#import numpy as np

abc='abcdefghijklmnopqrstuvwxyz'
abd={'a': 0, 'b': 1, 'c': 2, 'd': 3, 'e': 4, 'f': 5, 'g': 6, 'h': 7, 'i': 8, 'j': 9, 'k': 10, 'l': 11, 'm': 12, 'n': 13, 'o': 14, 'p': 15, 'q': 16, 'r': 17, 's': 18, 't': 19, 'u': 20, 'v': 21, 'w': 22, 'x': 23, 'y': 24, 'z': 25}
mod,MOD=1000000007,998244353
vow=['a','e','i','o','u']
dx,dy=[-1,1,0,0],[0,0,1,-1]

def all_factors(n):
    """returns a sorted list of all distinct factors of n"""
    small, large = [], []
    for i in range(1, int(n**0.5) + 1, 2 if n & 1 else 1):
        if not n % i:
            small.append(i)
            large.append(n // i)
    if small[-1] == large[-1]:
        large.pop()
    large.reverse()
    small.extend(large)
    return small

def get_array(): return list(map(int , sys.stdin.readline().strip().split()))
def get_ints(): return map(int, sys.stdin.readline().strip().split())
def input(): return sys.stdin.readline().strip()

n=int(input())
A=get_array()
B=get_array()
mydict_A=dict()
mydict_B=dict()
for i,j in zip(A,B):
    mydict_A[i]=mydict_A.get(i,0)+1
    mydict_B[j]=mydict_B.get(j,0)+1
score=[0]*6
for i,j in zip(A,B):
    score[i]+=1
    score[j]+=1
flag=0
for i in range(1,6):
    if score[i]&1:
        flag=1
        break

if flag==1:
    print(-1)
    exit(0)
contri_A=0;contri_B=0
for i in mydict_A:
    contri_A+=max(mydict_A[i]-(score[i]/2),0)
for i in mydict_B:
    contri_B+=max(mydict_B[i]-(score[i]/2),0)

if contri_A!=contri_B:
    print(-1)
    exit(0)
print(int(contri_A))

n = int(input())
a = list(map(int, input().strip().split()))
b = list(map(int, input().strip().split()))
s = 0
for i in range(1, 6):
    x = a.count(i)
    y = b.count(i)
    if not (x + y) % 2 == 0: exit(print(-1))
    else: s += abs(x - y) // 2
print(s // 2)

n = input()
f = list(map(str, input().split()))
s = list(map(str, input().split()))

od = abs(f.count('1')-s.count('1'))
sd = abs(f.count('2')-s.count('2'))
td = abs(f.count('3')-s.count('3'))
fd = abs(f.count('4')-s.count('4'))
vd = abs(f.count('5')-s.count('5'))

if od%2==0 and sd%2==0 and td%2==0 and fd%2==0 and vd%2==0 :
	print((od+sd+td+fd+vd)//4)
else :
	print(-1)

n = int(input())
a = list(map(int, input().split()))
b = list(map(int, input().split()))

numa = [0] * 5
numb = [0] * 5
for i in a:
	numa[i-1] += 1
for i in b:
	numb[i-1] += 1
failed = False
for i in range(0, 5):
	if ((numa[i] + numb[i]) % 2 == 1):
		failed = True
		break
steps = 0
if (failed):
	print(-1)

else:
	for i in range(0, 5):
		steps += abs(numa[i] - numb[i])/2
	print (int(steps/2))

import sys,os
from io import BytesIO, IOBase
import collections,itertools,bisect,heapq,math,string
# region fastio

BUFSIZE = 8192

BUFSIZE = 8192

class FastIO(IOBase):
    newlines = 0

    def __init__(self, file):
        self._fd = file.fileno()
        self.buffer = BytesIO()
        self.writable = "x" in file.mode or "r" not in file.mode
        self.write = self.buffer.write if self.writable else None

    def read(self):
        while True:
            b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
            if not b:
                break
            ptr = self.buffer.tell()
            self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr)
        self.newlines = 0
        return self.buffer.read()

    def readline(self):
        while self.newlines == 0:
            b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
            self.newlines = b.count(b"\n") + (not b)
            ptr = self.buffer.tell()
            self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr)
        self.newlines -= 1
        return self.buffer.readline()

    def flush(self):
        if self.writable:
            os.write(self._fd, self.buffer.getvalue())
            self.buffer.truncate(0), self.buffer.seek(0)

class IOWrapper(IOBase):
    def __init__(self, file):
        self.buffer = FastIO(file)
        self.flush = self.buffer.flush
        self.writable = self.buffer.writable
        self.write = lambda s: self.buffer.write(s.encode("ascii"))
        self.read = lambda: self.buffer.read().decode("ascii")
        self.readline = lambda: self.buffer.readline().decode("ascii")

sys.stdin, sys.stdout = IOWrapper(sys.stdin), IOWrapper(sys.stdout)
input = lambda: sys.stdin.readline().rstrip("\r\n")
# ------------------------------
def main():
    n = int(input())
    a = list(map(int, input().split()))
    b = list(map(int, input().split()))
    c = {}
    d = {}
    for i in range(n):
        if a[i] in c:
            c[a[i]] += 1
        else:
            c[a[i]] = 1
    for i in range(n):
        if b[i] in d:
            d[b[i]] += 1
        else:
            d[b[i]] = 1
    #print(c)
    #print(d)
    e = 0
    g = 0
    h = 0
    m = 0
    o = 0
    for i in c:
        if i in d:
            #e.append(i)
            if c[i] == d[i]:
                continue
            else:
                #m += 1
                if c[i] > d[i]:
                    g = abs(c[i] - d[i])
                else:
                    g = 0
                if(g%2 == 0):
                    h += g//2
                else:
                    h = -1
                    break
        else:
            g = c[i]
            if(g%2 == 0):
                e += g//2
            else:
                e = -1
                break
    for i in d:
        if i not in c:
            g = d[i]
            if(g%2 == 0):
                o += g//2
            else:
                o = -1

    #print(h,e,m,o)
    if(h == -1 or e == -1 or o == -1):
        e = -1
    else:
        #if(h > 0 and m > 0):
         #   h = h//m
        #if e+h > o:
         #   e = h+e-o
        #else:
        e = h+e
    print(e)

if __name__ == "__main__":
    main()

from collections import Counter

n = int(input())
a = input().split(' ')
b = input().split(' ')
aa = Counter()
bb = Counter()
for x in a:
    aa[x] += 1
for x in b:
    bb[x] += 1
mm = Counter()
possible = True
for x in ('1', '2', '3', '4', '5'):
    if (aa[x] + bb[x]) % 2 != 0:
        possible = False
    else:
        mm[x] = (aa[x] + bb[x]) // 2
if not possible:
    print('-1')
else:
    print(sum(abs(aa[x] - mm[x]) for x in ('1', '2', '3', '4', '5')) // 2)

import math

a = raw_input()
a = int(a)

b = raw_input()
c = raw_input()

b = b.split()
c = c.split()

b = map(int, b)
c = map(int, c)

count1 = 0
count2 = 0
count3 = 0
count4 = 0
count5 = 0
bount1 = 0
bount2 = 0
bount3 = 0
bount4 = 0
bount5 = 0

for i in range(a):
    if b[i] == 1:
        bount1 += 1
    elif b[i] == 2:
        bount2 += 1
    elif b[i] == 3:
        bount3 += 1
    elif b[i] == 4:
        bount4 += 1
    elif b[i] == 5:
        bount5 += 1

for i in range(a):
    if c[i] == 1:
        count1 += 1
    elif c[i] == 2:
        count2 += 1
    elif c[i] == 3:
        count3 += 1
    elif c[i] == 4:
        count4 += 1
    elif c[i] == 5:
        count5 += 1

if (bount1 + count1) % 2 == 1:
    print -1
elif (bount2 + count2) % 2 == 1:
    print -1
elif (bount3 + count3) % 2 == 1:
    print -1
elif (bount4 + count4) % 2 == 1:
    print -1
elif (bount5 + count5) % 2 == 1:
    print -1
else:
    count = 0
    if bount1 > (bount1 + count1)/2:
        count += bount1 - (bount1 + count1)/2
    if bount2 > (bount2 + count2)/2:
        count += bount2 - (bount2 + count2)/2
    if bount3 > (bount3 + count3)/2:
        count += bount3 - (bount3 + count3)/2
    if bount4 > (bount4 + count4)/2:
        count += bount4 - (bount4 + count4)/2
    if bount5 > (bount5 + count5)/2:
        count += bount5 - (bount5 + count5)/2
    print count

n = int(input())

s = list(map(int, input().split()))
p = list(map(int, input().split()))

a1 = s.count(1)
a2 = s.count(2)
a3 = s.count(3)
a4 = s.count(4)
a5 = s.count(5)

b1 = p.count(1)
b2 = p.count(2)
b3 = p.count(3)
b4 = p.count(4)
b5 = p.count(5)

z1 = abs(a1 - b1)
z2 = abs(a2 - b2)
z3 = abs(a3 - b3)
z4 = abs(a4 - b4)
z5 = abs(a5 - b5)

ans1 = (z1 + z2 + z3 + z4 + z5)//2

if z1 % 2==0 and z2 % 2==0 and z3 % 2==0 and z4 % 2==0 and z2 % 2==0 :
	if ans1 % 2 == 0 :
		print(ans1 // 2)
	else:
		print("-1")
else :
	print("-1")

a=input()
l1=raw_input().split(' ')
l2=raw_input().split(' ')

def make_dic(li):
    d=dict()
    for h in li:
        if h not in d:
            d[h]=1
        else:
            d[h]+=1
    return d
d1=make_dic(l1)
d2=make_dic(l2)

#c=0
def count(d1,d2):
    c=0
    for h in d1:
        if h in d2:
            if (d1[h]+d2[h])%2==0:

                if d1[h]>d2[h]:
                    c=c+(d1[h]-d2[h])/2
                else:
                    c=c+(d2[h]-d1[h])/2
            else:
                return -1
        else:
            if d1[h]%2==0:
                c=c+(d1[h]/2)
            else:
                return -1
    for h in d2:
        if h not in d1:
            if d2[h]%2==0:
                c=c+(d2[h]/2)
            else:
                return -1
    return c/2

print count(d1,d2)

import sys

diff = [0] * 6

[n] = [int(x) for x in sys.stdin.readline().split()]
a = [int(x) for x in sys.stdin.readline().split()]
b = [int(x) for x in sys.stdin.readline().split()]

for x in a:
	diff[x] += 1

for x in b:
	diff[x] -= 1

res = 0

for x in diff:
	if x % 2 != 0:
		print -1
		sys.exit()
	else:
		res += abs(x / 2)

print res / 2

'''
===
4
5 4 4 4
5 5 4 5
---
1
===
6
1 1 1 1 1 1
5 5 5 5 5 5
---
3
===
1
5
3
---
-1
===
9
3 2 5 5 2 3 3 3 2
4 1 4 1 1 2 4 4 1
---
4
===
'''

n=input()
a=map(int,raw_input().split())
b=map(int,raw_input().split())
cnt=[0 for i in range(6)]
cnta=[0 for i in range(6)]
cntb=[0 for i in range(6)]

for i in range(n):
    cnt[a[i]]+=1
    cnt[b[i]]+=1
    cnta[a[i]]+=1
    cntb[b[i]]+=1

for i in range(6):
    if cnt[i]%2==1:
        print -1
        exit(0)
    else:
        cnt[i]/=2

ans=0
for i in range(6):
    if cnta[i]>cnt[i]:
        ans+=cnta[i]-cnt[i]

print ans

import sys
import itertools

def solve(A, B):
  totals = [a+b for a,b in itertools.izip(A, B)]
  swaps = 0
  for num,a,b in itertools.izip(totals, A, B):
    if num % 2:
      return -1
    needed = num / 2
    swaps += abs(needed - a)

  if swaps % 2:
    return -1
  else:
    return swaps / 2

def main():
  n = int(sys.stdin.readline())
  g_A = map(int, sys.stdin.readline().split())
  g_B = map(int, sys.stdin.readline().split())
  A = [0 for i in xrange(5)]
  B = [0 for i in xrange(5)]

  for n in g_A:
    A[n-1] += 1
  for n in g_B:
    B[n-1] += 1

  print solve(A, B)

if __name__ == '__main__':
  main()

R=lambda:map(int,raw_input().split())
input()
c=[0]*8
for x in R():
  c[x]+=1
for x in R():
  c[x]-=1
t=0
for x in range(1,6):
  if c[x]%2:
    print -1
    break
  t+=abs(c[x])/2
else:
  print t/2

import sys
f = sys.stdin
#f = open('779A.txt')

n = int(f.readline())
tab1 = [0]*101
tab2 = [0]*101
all = [0]*101
ans = 0
u1 = [int(i) for i in f.readline().split()]
u2 = [int(i) for i in f.readline().split()]
for _ in xrange(0, n):
    tab1[u1[_]] += 1
    #tab2[u2[_]] += 1
    all[u1[_]] += 1
    all[u2[_]] += 1
ok = 1
for _ in xrange(0, 101):
    if all[_] > 0:
        if all[_] % 2 <> 0:
            ok = 0
            break
        else:
            tab2[_] = all[_] / 2
for _ in xrange(0, 101):
    if all[_] == 0:
        continue
    ans += abs(tab1[_] - tab2[_])
if ok == 0:
    print -1
else:
    print ans/2
#f.close

from sys import stdin
n = int(stdin.readline().strip())
a = map(int,stdin.readline().split())
b = map(int,stdin.readline().split())
di = {}
fi = {}
for i in a:
    di[i] = di.get(i,0)+1
    fi[i] = fi.get(i,0) + 1
for i in b:
    di[i] = di.get(i,0) + 1
ans = 0
cur = 0
for i in di:
    if di[i]%2:
        ans = -1
        break
    x = di[i]/2
    if fi.get(i,0) > x:
        ans += fi.get(i,0) - x
print ans

import sys

def main(argv):
	N = int(raw_input())

	A = [int(x) for x in raw_input().split(' ')]
	B = [int(x) for x in raw_input().split(' ')]

	count_A = {}
	count_B = {}

	for val in xrange(1, 6):
		count_A[val] = count_B[val] = 0

	for val in A:
		if val in count_A:
			count_A[val] += 1
		else:
			count_A[val] = 1

	for val in B:
		if val in count_B:
			count_B[val] += 1
		else:
			count_B[val] = 1

	ans = 0
	from_A = 0
	from_B = 0
	for val in xrange(1, 6):
		if count_A[val] > count_B[val]:
			from_A += abs(count_A[val] - (count_A[val] + count_B[val]) / 2)
		else:
			from_B += abs(count_A[val] - (count_A[val] + count_B[val]) / 2)
		ans += abs(count_A[val] - (count_A[val] + count_B[val]) / 2)

	if from_A != from_B:
		print -1
	else:
		print ans / 2

if __name__ == '__main__':
	main(sys.argv)

from random import random
import math
import re
import fractions

N = input()
# N, M = map(int, raw_input().split(" "))
A = map(int, raw_input().split(" "))
B = map(int, raw_input().split(" "))
s = [0]*5
a = [0]*5
for i in xrange(N):
    s[A[i]-1] += 1
    a[A[i]-1] += 1
    s[B[i]-1] += 1
f = True
r = 0
# print s, a
for i in xrange(5):
    if s[i] % 2:
        print -1
        break
    else:
        r += abs(s[i]/2 - a[i])
else:
    print r/2

import sys
from collections import Counter

n = int(input())
a = Counter(map(int, input().split()))
b = Counter(map(int, input().split()))

counta = 0
countb = 0

for i in range(1,5+1):
    diff = abs(a[i] - b[i])
    if diff%2:
        print(-1)
        sys.exit(0)

    if a[i] < b[i]:
        countb += int(diff/2)
    if b[i] < a[i]:
        counta += int(diff/2)

if counta != countb:
    print(-1)
    sys.exit(0)

print(counta)

n = input()
A = map(lambda x: int(x)-1, raw_input().split())
B = map(lambda x: int(x)-1, raw_input().split())
c = [0 for _ in xrange(5)]

for a in A:
    c[a] += 1
for b in B:
    c[b] += 1

if not all(x % 2 == 0 for x in c):
    print -1
    exit()

d = [x / 2 for x in c]
ans = 0
ca = [0 for _ in xrange(5)]
for a in A:
    ca[a] += 1

for i in xrange(5):
    ans += abs(d[i] - ca[i])

print ans/2

n = int(raw_input())
m1 = map(int, raw_input().split(" "))
m2 = map(int, raw_input().split(" "))

cm1 = [0]*6
for m in m1:
   cm1[m]+=1
cm2 = [0]*6
for m in m2:
   cm2[m]+=1

r = 0
for m in range(1,6):
    d = abs(cm1[m]-cm2[m])
    if d%2:
        print -1
        exit()
    r+= (d/2)
print r/2

n = int(input())
a = [int(i) for i in input().split(' ')]
b = [int(i) for i in input().split(' ')]

count = [0]*6

for i in range(1, 6):
    count[i] = a.count(i) - b.count(i)

ans = 0

for i in range(1, 6):
    for j in range(i+1, 6):
        if count[i] * count[j] < 0:
            t = min(abs(count[i]), abs(count[j]))//2
            ans += t
            count[i] += t*2 if count[i] < 0 else -t*2;
            count[j] += t*2 if count[j] < 0 else -t*2;

if count.count(0) == 6:
    print(ans)
else:
    print(-1)

n = input()
A = map(int, raw_input().split())
B = map(int, raw_input().split())

da = {x:0 for x in range(1, 6)}
db = {x:0 for x in range(1, 6)}

for x in A:
	da[x]+=1
for x in B:
	db[x]+=1

ans = 0
extra = []
for ii in range(1, 6):
	if da[ii] == db[ii]:
		continue
	if (da[ii] + db[ii]) & 1:
		print '-1'
		exit(0)
	else:
		extra.append(abs(db[ii] - da[ii]) / 2)

print sum(extra)/2

# -*- coding: utf-8 -*-
n = int(input())
c1 = list(map(int, input().split(' ')))
c2 = list(map(int, input().split(' ')))
m1_add = []
m1_rem = []
m2_add = []
m2_rem = []
boolean = True
for i in range(1, 6):
    k1 = c1.count(i)
    k2 = c2.count(i)
    if abs(k1-k2)%2 == 1:
        print(-1)
        boolean = False
        break
    if k1>k2:
        m1_rem.append((k1-k2)//2)
        m2_rem.append(0)
        m1_add.append(0)
        m2_add.append((k1-k2)//2)
    else:
        m1_rem.append(0)
        m2_rem.append((k2-k1)//2)
        m1_add.append((k2-k1)//2)
        m2_add.append(0)
if boolean:
    for i in range(5):
        for j in range(m1_add[i]):
            c1.append(i+1)
        for j in range(m2_add[i]):
            c2.append(i+1)
        for j in range(m1_rem[i]):
            c1.remove(i+1)
        for j in range(m2_rem[i]):
            c2.remove(i+1)
    if sum([int(i) for i in c1]) == sum([int(i) for i in c2]):
        print(sum(m1_add))
    else:
        print(-1)

n=input()
a=map(int,raw_input().split())
b=map(int,raw_input().split())
dp=[0]*6
for i in a:
    dp[i]+=1
for i in b:
    dp[i]+=1

for item in dp:
    if item%2==1:
        print -1
        break
else:
    dpa=[0]*6
    dpb=[0]*6
    for i in a:
        dpa[i]+=1
    for i in b:
        dpb[i]+=1
    total=0
    for i in xrange(len(dp)):
        total=total+(abs(dp[i]/2-dpa[i]))
    print total/2

n = int(raw_input())
a = map(int, raw_input().split())
b = map(int, raw_input().split())

arr = [0]*6
brr = [0] * 6
poscount = 0
count = 0
for i in range(n):
    arr[a[i]] += 1
    brr[b[i]] += 1
#print arr, brr

for i in range(1, 6):
    if ((arr[i] - brr[i]) % 2 != 0):
        print -1
        exit(0)
    else:
        count += (arr[i] - brr[i])/2
        poscount += abs(arr[i] - brr[i])/2

if (count):
    print -1
else:
    print poscount/2

n = input()

A = map(int,raw_input().split())
B = map(int,raw_input().split())

A_cnt = list(A.count(i) for i in range(1,6))
B_cnt = list(B.count(i) for i in range(1,6))

ans = 0

for a,b in zip(A_cnt,B_cnt):
    if (a - b) % 2 != 0:
        print -1
        break
    else:
        if a - b > 0:
            ans += a-b

else:
    print ans/2

n = int(input())
adata = {
    1:0,
    2:0,
    3:0,
    4:0,
    5:0
}
bdata= {
    1:0,
    2:0,
    3:0,
    4:0,
    5:0
}

a = list(map(int,input().split()))
for x in a:
    adata[x] = adata[x] + 1
b = list(map(int,input().split()))
for x in b:
    bdata[x] = bdata[x] + 1
ans = 0
ans = ans + abs(adata[1]-bdata[1])
ans = ans + abs(adata[2]-bdata[2])
ans = ans + abs(adata[3]-bdata[3])
ans = ans + abs(adata[4]-bdata[4])
ans = ans + abs(adata[5]-bdata[5])
if (adata[1]+bdata[1])%2!=0 or (adata[1]+bdata[1])%2!=0  or (adata[2]+bdata[2])%2!=0  or (adata[3]+bdata[3])%2!=0  or (adata[4]+bdata[4])%2!=0  or (adata[5]+bdata[5])%2!=0 :
    ans = -1
print(ans//4)

n = int(input())
x1 = list(map(int, input().split()))
x2 = list(map(int, input().split()))
ans = 0
count1 = [0,0,0,0,0,0]
count2 = [0,0,0,0,0,0]
flag = True
for i in range(1, 6):
 s = x1.count(i) + x2.count(i)
 count1[i] = x1.count(i)
 count2[i] = x2.count(i)
 if(s%2==1):
  flag = False
  break

if(flag):
 x1.sort()
 x2.sort()
 for i in range(1, 6):
  for j in range(min(count1[i], count2[i])):
   x1.remove(i)
   x2.remove(i)
   count1[i]-=1
   count2[i]-=1
 l = len(x1)
 print(l//2)
else:
 print(-1)

n = int(input())
a = list(map(int, input().split()))
b = list(map(int, input().split()))
c = [0,0,0,0,0]
for i in a:
    c[i - 1] += 1
for j in b:
    c[j - 1] -= 1
c = [abs(i) for i in c]
import sys
for i in c:
    if i % 2:
        print(-1)
        sys.exit(0)
print(sum(c) // 4)

input()

fst = [int(x) for x in input().split()]
snd = [int(x) for x in input().split()]

def count(arr):
    res = {i: 0 for i in range(1, 6)}
    for i in arr:
        res[i]+=1
    return res

def solve():
    total = count(fst+snd)
    fst_ = count(fst)
    snd_ = count(snd)

    for v in total.values():
        if v%2!=0: return -1
    res = 0
    for k, v in fst_.items():
        diff = v - total[k]//2
        res += (diff if diff>0 else 0)
    return res
print(solve())

n = int(input().strip())
a = list(map(int, input().strip().split()))
b = list(map(int, input().strip().split()))
fa, fb = [0]*6, [0]*6
for i in range(n):
	fa[a[i]] += 1
	fb[b[i]] += 1
total = 0
for i, j in zip(fa, fb):
	if (i+j)%2:
		exit(print(-1))
	total += abs(i-j)//2
print(total//2)

n=int(input())
a=list(map(int, input().split()))
b=list(map(int, input().split()))
for i in range(1,6):
    if (a.count(i)+b.count(i))%2==1:
        print(-1)
        exit()
ans=0
for i in range(1,6):
    ans+=abs(a.count(i)-b.count(i))
print(ans//4)

input()

A,B = input(),input()

D = [abs(A.count(x)- B.count(x)) for x in '12345']
print(-1 if any(d % 2 for d in D) else sum(D) //4)

# helper methods for input
def ri():
    return raw_input()

def ii(type):
    x = ri()
    if type == 'i':
        return int(x)
    if type == 'l':
        return long(x)
    if type == 'f':
        return float(x)
    if type == 's':
        return str(x)
    return

def i2(type):
    x = ri().split()
    if type == 'i':
        return int(x[0]), int(x[1])
    if type == 'l':
        return long(x[0]), long(x[1])
    if type == 'f':
        return float(x[0]), float(x[1])
    if type == 's':
        return str(x[0]), str(x[1])
    return

def ni(type):
    array = ri().split()
    def doforall(x):
        if type == 'i':
            return int(x)
        if type == 'l':
            return long(x)
        if type == 'f':
            return float(x)
        if type == 's':
            return str(x)
        return
    array = map(doforall, array)
    return array

def pr(array):
    def tostring(el):
        return str(el)
    print ' '.join(map(tostring, array))

def fndec(x):
    return '{0:.6f}'.format(x)

# main
n = ii('i')
arr1 = ni('i')
arr2 = ni('i')
allarr = arr1 + arr2

dic = {}
for elem in allarr:
    if elem not in dic: dic[elem] = 0
    dic[elem] += 1

possible = True
for key in dic:
    if dic[key] % 2 == 1:
        possible = False
        break
    else:
        dic[key] /= 2

if not possible:
    print '-1'
else:
    count = 0
    for elem in arr1:
        if dic[elem] > 0:
            dic[elem] -= 1
        else:
            count += 1
    print count

n = int(input())
#m = input().split() #list
#[a, b, c] = [int(x) for x in input().split()]
A = [int(x) for x in input().split()]
B = [int(x) for x in input().split()]

A_grades = [0, 0, 0, 0, 0]
B_grades = [0, 0, 0, 0, 0]

for i in range(0, n):
    A_grades[A[i]-1] += 1
    B_grades[B[i]-1] += 1

l = 0

#Check if such changes can happen
for i in range(0, 5):
    if (A_grades[i] + B_grades[i]) % 2 != 0:
        print(-1)
        l = 1
        break

dif = 0
for i in range(0, 5):
    dif += abs(A_grades[i]- B_grades[i])

if l == 0:
    print(dif // 4)

# MELISSA MOORE
n=input()
a=map(int, raw_input().split())
b=map(int, raw_input().split())
s=0
for t in range(1,6):
    if (a+b).count(t)%2==1:
        s=-2
        break
    else:
        s+=abs(a.count(t)-b.count(t))
print s/4

import sys
import math
import itertools
import collections

def getdict(n):
    d = {}
    if type(n) is list or type(n) is str:
        for i in n:
            if i in d:
                d[i] += 1
            else:
                d[i] = 1
    else:
        for i in range(n):
            t = ii()
            if t in d:
                d[t] += 1
            else:
                d[t] = 1
    return d
def divs(n, start=1):
    r = []
    for i in range(start, int(math.sqrt(n) + 1)):
        if (n % i == 0):
            if (n / i == i):
                r.append(i)
            else:
                r.extend([i, n // i])
    return r
def cdiv(n, k): return n // k + (n % k != 0)
def ii(): return int(input())
def mi(): return map(int, input().split())
def li(): return list(map(int, input().split()))
def lcm(a, b): return abs(a*b) // math.gcd(a, b)
def wr(arr): return ''.join(map(str, arr))
def revn(n): return int(str(n)[::-1])
def prime(n):
    if n == 2: return True
    if n % 2 == 0 or n <= 1: return False
    sqr = int(math.sqrt(n)) + 1
    for d in range(3, sqr, 2):
        if n % d == 0: return False
    return True
def nconv(number, base=3):
    newnumber = ''
    while number > 0:
        newnumber = str(number % base) + newnumber
        number //= base
    return newnumber

n = ii()
a = li()
b = li()
for i in range(5):
    if (a.count(i + 1) + b.count(i + 1)) % 2 != 0:
        print(-1)
        exit()
ans = 0
for i in range(5):
    ans += abs(a.count(i + 1) - b.count(i + 1)) // 2
print(ans // 2)

n = int(raw_input())
a = map(int, raw_input().split())
b = map(int, raw_input().split())

numberOfExchange = 0

for i in xrange(0,5):
	if (a.count(i+1) + b.count(i+1)) % 2 != 0 :
		numberOfExchange = -1
		break
	numberOfExchange += abs(a.count(i+1)-b.count(i+1))/2

print numberOfExchange/2

n=int(input())
l=list(map(int,input().split()))
l1=list(map(int,input().split()))
c=[0]*(8)
ans=0
for i in l:
    #print(i-1)
    c[i]+=1
for i in l1:
    c[i]-=1

for i in range(6):
    if c[i]%2:
        print(-1)
        break
    ans+=abs(c[i])//2
else:print(ans//2)

from sys import stdin
from collections import defaultdict

n = int(input())
a = [int(x) for x in input().split()]
b = [int(x) for x in input().split()]
a_d = defaultdict(int)
b_d = defaultdict(int)
for i in range(n):
    a_d[a[i]] += 1
    b_d[b[i]] += 1
f = True
ans = 0
for i in range(6):
    if (a_d[i] + b_d[i]) % 2:
        f = False
        break
    ans += abs(a_d[i] - b_d[i])
if f:
    print(ans//4)
else:
    print(-1)

import sys

n = int(sys.stdin.readline())
a = list(map(int, sys.stdin.readline().split()))
b = list(map(int, sys.stdin.readline().split()))
ans = 0

am = [0] * 5
bm = [0] * 5

for i in a:
    am[i - 1] += 1
for i in b:
    bm[i - 1] += 1

for i in range(5):
    if am[i] != bm[i]:
        if (am[i] - bm[i]) % 2 == 0:
            ans += abs(am[i] - bm[i]) // 2
        else:
            ans = -1
            break
print(ans // 2)

ans=0
n=int(input())
a=[int(i) for i in input().split()]
b=[int(i) for i in input().split()]
x={i:0 for i in range(1,6)}
y={i:0 for i in range(1,6)}
for i in a:
    x[i]+=1
for i in b:
    y[i]+=1
ans=[0]*2
for i in range(1,6):
    tmp=x[i]-y[i]
    if tmp%2!=0:
        print(-1)
        exit()
    elif tmp>0:
        ans[1]+=tmp
    else:
        ans[0]+=tmp
print(ans[1]//2 if sum(ans)==0 else -1)

r=lambda:map(int,raw_input().split())

n=input()
a=r()
b=r()
c=a+b
s=set(a+b)

R=0
for e in s:
    if c.count(e)%2:
        print -1
        exit(0)
    R+= abs(c.count(e)/2-a.count(e))

print R/2

n = int(input())
a = list(map(int,input().split()))
b = list(map(int,input().split()))
c=0
d=0
z=0
for j in range(5):
    for i in range(n):
        if a[i]==j+1:
            c+=1
    for i in range(n):
        if b[i]==j+1:
            d+=1
    if (c+d)%2==1:
        z=-2
        break
    else:
        z+=abs(c-d)//2
    d=0
    c=0
print(z//2)

n = int(raw_input())
a = map(int, raw_input().split())
b = map(int, raw_input().split())
a_i = {i : a.count(i) for i in xrange(1, 6)}
b_i = {i : b.count(i) for i in xrange(1, 6)}
possible = True

tot_diff = 0
for i in xrange(1, 6):
    if a_i[i] != b_i[i]:
        diff = abs(a_i[i] - b_i[i])
        if diff % 2 == 1:
            possible = False
        tot_diff += diff/2
if possible:
    print tot_diff / 2
else:
    print -1

n=int(raw_input())
a=map(int,raw_input().split())
b=map(int,raw_input().split())
ans=[]
f=count=0
for i in range(1,6):
	ans.append(a.count(i)-b.count(i))
ans.sort()
for i in range(len(ans)):
	if ans[i]%2!=0:
		f=1
		break
if f==1 or sum(ans)!=0:
	print -1
	exit(0)
for i in range(len(ans)):
	if ans[i]<0:
		count+=abs(ans[i])/2
	else:
		break
print count

R=lambda:map(int,raw_input().split())
R()
c=[0]*8
for x in R():c[x]+=1
for x in R():c[x]-=1
t=0
for x in range(1,6):
 if c[x]%2:
  print -1
  break
 t+=abs(c[x])/2
else:print t/2

n = input()

a = map(int, raw_input().split())
b = map(int, raw_input().split())

#print n, a, b

#c = a + b
sa = [0] * 5
sb = [0] * 5
for i in xrange(n):
    sa[a[i]-1] = sa[a[i]-1] + 1
    sb[b[i]-1] = sb[b[i]-1] + 1

#print s

for i in xrange(5):
    if (sa[i] + sb[i]) % 2 != 0:
        print -1
        exit()

s = 0
for i in xrange(5):
    s = s + abs(sa[i] - sb[i])/2

print s/2

input()
A, B = input(), input()
D = [abs(A.count(x) - B.count(x)) for x in '12345']
#first divide by 2 for overcounting,Now if you pick a number you pick another number as
#if sum is odd like 17 or 19 then -1,if divisible by 4,great,if divisible by 2 but not 4
#then floor 4 because numbers like 9,25,27 all have a remaining pair after 8*2,24*2,26*2.
print(-1 if any(d % 2 for d in D) else sum(D) // 4)

n = int(raw_input())
a = map(int, raw_input().strip().split(' '))
b = map(int, raw_input().strip().split(' '))

countA = [0 for i in xrange(6)]
countB = [0 for i in xrange(6)]
for i in a:
    countA[i] += 1

for i in b:
    countB[i] += 1

ans = 0
for i in xrange(6):
    #print countA[i], countB[i]
    if (countA[i] + countB[i]) % 2 == 1:
        print -1
        exit(0)
    diff = abs(countA[i] - countB[i])
    ans += diff/ 2

print ans / 2

def get(l):
    a=[0]*5
    for i in xrange(n):
        a[l[i]-1]+=1
    return a
n=input()
p=map(int,raw_input().split())
q=map(int,raw_input().split())
a,b=get(p),get(q)
p=0
ans=0
#print a
#print b
for i in xrange(5):
    t=(a[i]+b[i])/2
    if (a[i]+b[i])%2!=0:
        p=1
        break
    else:
        #print "sdjv"
        ans+=(abs(a[i]-t))
        p+=(a[i]-t)
        #print a[i],t
    #print t,ans,p
if p==0:
    print ans/2
else:
    print -1

n = input()
group_a = map(int, raw_input().split())
group_b = map(int, raw_input().split())
a = [0]*6
b = [0]*6

for num in group_a:
    a[num] += 1

for num in group_b:
    b[num] += 1

valid = True
differences = 0
for i in range(6):
    if (a[i] + b[i]) % 2 == 1:
        valid = False
    else:
        differences += abs((a[i] - b[i]) / 2)

if valid:
    print differences / 2
else:
    print -1

n = int(raw_input())
a = map(int, raw_input().strip().split(' '))
b = map(int, raw_input().strip().split(' '))

countA = [0 for i in xrange(6)]
countB = [0 for i in xrange(6)]
for i in a:
    countA[i] += 1

for i in b:
    countB[i] += 1

ans = 0
for i in xrange(6):
    #print countA[i], countB[i]
    if (countA[i] + countB[i]) % 2 == 1:
        print -1
        exit(0)
    diff = abs(countA[i] - countB[i])
    ans += diff / 2

print ans / 2

n = int(input())

a = list(map(int, input().strip().split(" ")))
b = list(map(int, input().strip().split(" ")))

count = [0] * 5

for grade in a:
    count[grade - 1] +=1

for grade in b:
    count[grade - 1] -=1

suma = 0
flag = True
for item in count:
    if(item % 2 == 1):
        flag = False
        break;
    else:
        suma += abs(item) // 2

if(flag):
    print(suma // 2)
else:
    print(-1)

read = lambda: map(int, input().split())
n = int(input())
a = sorted(read())
b = sorted(read())
for i in range(1, 6):
    if (a.count(i) + b.count(i)) % 2:
        print(-1)
        exit()
cnt = 0
while 1:
    flag = False
    for i in range(n):
        if a.count(a[i]) > b.count(a[i]):
            for j in range(n):
                if a.count(b[j]) < b.count(b[j]) and a[i] != b[j]:
                    a[i], b[j] = b[j], a[i]
                    cnt += 1
                    break
            if flag: break
    if not flag:
        break
print(cnt)

n = int(raw_input())
a = map(int, raw_input().strip().split(' '))
b = map(int, raw_input().strip().split(' '))

countA = [0 for i in xrange(6)]
countB = [0 for i in xrange(6)]
for i in a:
    countA[i] += 1

for i in b:
    countB[i] += 1

ans = 0
for i in xrange(6):
    #print countA[i], countB[i]
    if (countA[i] + countB[i]) % 2 == 1:
        print -1
        exit(0)
    diff = abs(countA[i] - countB[i])
    ans +=  diff / 2

print ans / 2

#!/usr/bin/python
# coding: utf-8

n=int(raw_input())
a=map(int,raw_input().split(' '))
b=map(int,raw_input().split(' '))
arr1=[0]*6
arr2=[0]*6
for i in xrange(n):
    arr1[a[i]]+=1
    arr2[b[i]]+=1
cnt=0
for i in xrange(1,6):
    exch=abs(arr1[i]-arr2[i])
    if(exch&1):
        cnt=-2
        break
    else:
        cnt+=(exch/2)
print cnt/2

'''

In Berland each high school student is characterized by academic performance — integer value between 1 and 5.

In high school 0xFF there are two groups of pupils: the group A and the group B. Each group consists of exactly n students. An academic performance of each student is known — integer
value between 1 and 5.

The school director wants to redistribute students between groups so that each of the two groups has the same number of students whose academic performance is equal to 1, the same
number of students whose academic performance is 2 and so on. In other words, the purpose of the school director is to change the composition of groups, so that for each value of
academic performance the numbers of students in both groups are equal.

To achieve this, there is a plan to produce a series of exchanges of students between groups. During the single exchange the director selects one student from the class A and one
student of class B. After that, they both change their groups.

Print the least number of exchanges, in order to achieve the desired equal numbers of students for each academic performance.

Input
The first line of the input contains integer number n (1 ≤ n ≤ 100) — number of students in both groups.
The second line contains sequence of integer numbers a1, a2, ..., an (1 ≤ ai ≤ 5), where ai is academic performance of the i-th student of the group A.
The third line contains sequence of integer numbers b1, b2, ..., bn (1 ≤ bi ≤ 5), where bi is academic performance of the i-th student of the group B.

Output
Print the required minimum number of exchanges or -1, if the desired distribution of students can not be obtained.

Examples
Input
4
5 4 4 4
5 5 4 5

Output
1

Input
6
1 1 1 1 1 1
5 5 5 5 5 5

Output
3

Input
1
5
3

Output
-1

Input
9
3 2 5 5 2 3 3 3 2
4 1 4 1 1 2 4 4 1

Output
4

'''

n=int(input())
a=list(map(int,input().split()))
b=list(map(int,input().split()))
s=0
c=0
for i in range(1,6):
	x=a.count(i)
	y=b.count(i)
	if((x+y)%2==0):
		s=s+(abs(x-y))//2
	else:
		c=1
		break
if(c==1):
	print(-1)
else:
	print(s//2)

n = int(input())
a = list(map(int, input().split()))
b = list(map(int, input().split()))

total = 0
for i in range(1, 6):
    aCnt, bCnt = a.count(i), b.count(i)
    if (aCnt + bCnt) % 2:
        total = -2
        break
    else:
        total += abs(aCnt - bCnt) // 2

print(total // 2)

import itertools
from fractions import gcd
from math import sqrt,ceil
from bisect import bisect_left , bisect_right
import heapq
from collections import deque
from itertools import combinations as C

def Ls():
	return list(raw_input())
def get(a):
	return map(a , raw_input().split())
def Int():
	return int(raw_input())
def Str():
	return raw_input()
from collections import defaultdict , deque , Counter
#last one:)
n = input()
ls1  = [0]*5
ls2  = [0]*5
h1 = get(int)
h2 = get(int)
for i in h1:
	ls1[i-1] += 1
for i in h2:
	ls2[i-1] += 1
#print ls1,ls2
if all( (ls1[i] + ls2[i]) % 2 == 0 for i in xrange(5)):
	pass
else:
	print -1
	exit(0)
cnt = 0
for i in xrange(5):
	a = ls1[i]
	b = ls2[i]
	mv = (a+b)/2 - min(a,b)
	if a > b:
		for j in xrange(5):
			a , b = ls1[j],ls2[j]
			if a < b:
				while mv > 0 and ls1[j] < ls2[j]:
					ls2[j] -= 1
					ls1[j] += 1
					mv -= 1
					cnt += 1
	elif a < b:
		for j in xrange(5):
			a , b = ls1[j],ls2[j]
			if a > b:
				while mv > 0 and ls1[j] < ls2[j]:
					ls2[j] += 1
					ls1[j] -= 1
					mv -= 1
					cnt += 1

print cnt

n=int(input())
a=list(map(int,input().split()))
b=list(map(int,input().split()))
c1=[0]*6
c2=[0]*6
for i in range (n):
    c1[a[i]]+=1
    c2[b[i]]+=1
x=0
for i in range(6):
    if((c1[i]+c2[i])%2 !=0):
        print(-1)
        exit()

    else:
        x+=(abs(c1[i]-c2[i])//2)

print(x//2)

from collections import defaultdict

n = int(input())
aa = map(int, input().split())
bb = map(int, input().split())

q = defaultdict(int)
w = defaultdict(int)
e = defaultdict(int)

for a in aa:
    q[a] += 1
    e[a] += 1

for b in bb:
    w[b] += 1
    e[b] += 1

ans = 0
for i in range(1, 6):
    if e[i] % 2 != 0:
        ans = -1
        break
    ans += abs(q[i] - (e[i] // 2))

print(ans // 2)

#!/usr/bin/python
# -*- coding: UTF-8 -*-

n = int(raw_input())
l1 = map(int, raw_input().split())
l2 = map(int, raw_input().split())
l1.sort()
l3 = l1 + l2
l4 = []
mark = 0
for x in xrange(1, 6):
    if l3.count(x) % 2 == 0:
        for y in xrange(l3.count(x) / 2):
            l4.append(x)
    else:
        mark = -1
        break
if mark == -1:
    pass
else:
    mark = 0
    l4.sort()
    for x in xrange(1,6):
        if l4.count(x) <= l1.count(x):
            pass
        else:
            mark += l4.count(x) - l1.count(x)
print mark

n = int(input())
G = {}
s = 0

for i in range(1, 6):
    G[i] = 0

for x in map(int, input().split()):
    G[x] += 1

for x in map(int, input().split()):
    G[x] -= 1

for i in range(1,6):
    if G[i] % 2 == 1:
        print(-1)
        exit(0)
    s += abs(G[i])

print(s // 4)

import sys
n=int(sys.stdin.readline())
A=list(map(int,sys.stdin.readline().split()))
B=list(map(int,sys.stdin.readline().split()))
l1=[0]*6
l2=[0]*6
for i in range(n):
    l1[A[i]]+=1
    l2[B[i]]+=1
flag=True
ans=0
for i in range(1,6):
    x=l1[i]+l2[i]
    if x%2!=0:
        flag=False
        break
    ans+=abs(x//2-l1[i])
if flag:
    print(ans//2)
else:
    print(-1)

import math as mt
import sys,string
input=sys.stdin.readline
import random
from collections import deque,defaultdict
L=lambda : list(map(int,input().split()))
Ls=lambda : list(input().split())
M=lambda : map(int,input().split())
I=lambda :int(input())
n=I()
a=L()
b=L()
da=defaultdict(int)
db=defaultdict(int)
for i in a:
    da[i]+=1
for j in b:
    db[j]+=1
s=list(set(list(da.keys())+list(db.keys())))

for i in s:
    if((da[i]+db[i])%2==1):
        print(-1)
        exit()

ans=0
for i in set(a):
    if(da[i]>(da[i]+db[i])//2):
       # print(i)
        p=(da[i]+db[i])//2
        ans+=abs(p-da[i])
for i in set(b):
    if(db[i]>(da[i]+db[i])//2):
       # print(i)
        p=(da[i]+db[i])//2
        ans+=abs(p-db[i])

print(ans//2)

x = int(input())
a = list(map(int,input().split()))
b = list(map(int,input().split()))
s = a + b
t = list(set(s))
k = 0
k1 = 0
flag = 0
d = {}
for i in range(len(t)):
	r = a.count(t[i])
	r1 = b.count(t[i])
	if (r-r1)%2 == 1 or (r1-r)%2 == 1:
		print(-1)
		flag = 1
		break
	elif r > r1:
		k = k + r - r1
	else:
		k1 = k1 + r1 - r
if k%2 == 0 and k == k1 and flag == 0:
	print(k//2)
elif flag == 0:
	print(-1)

l=lambda:map(int,raw_input().split())
n=input()
a1=l()
a2=l()
d1={}
d2={}
for v in a1:
    d1[v]=d1.get(v,0)+1
for v in a2:
    d2[v]=d2.get(v,0)+1
for k in range(1,6):
    if abs(d1.get(k,0)+d2.get(k,0))%2<>0:
        print -1
        exit()
print sum(abs(d1.get(k,0)-d2.get(k,0))/2 for k in range(1,6))/2

n=int(input())
a=list(map(int,input().split()))
b=list(map(int,input().split()))
fa=[0]*(6)
fb=[0]*(6)
for i in a:
	fa[i]+=1
for i in b:
	fb[i]+=1
ans=0
for i in range(6):
	xx=fa[i]+fb[i]
	if xx%2==1:
		print(-1)
		exit()
	else:
		xx=xx//2
		ans+=min(abs(xx-fa[i]),abs(xx-fb[i]))
print(ans//2)

n = int(input())
a = list(map(int, input().split()))
b = list(map(int, input().split()))
ans = 0
for i in range(1, 6):
    x, y = a.count(i), b.count(i)
    if (x+y) & 1:
        ans = -1
        break
    ans += abs(x - y) // 2
print(ans//2)

# read data
N = int( raw_input())
groupA_raw = map( int, raw_input().split() )
groupB_raw = map( int, raw_input().split() )

groupA = [0]*5
groupB = [0]*5

# count amount of students with all ratings
for i in range(N):
	groupA[ groupA_raw[i] - 1 ] += 1
	groupB[ groupB_raw[i] - 1 ] += 1

sum_d = 0
sum_abs_d = 0
difference = [0]*5
for i in range(5):
	difference[i] = (groupA[i] - groupB[i]) // 2
	sum_d += difference[i]
	sum_abs_d += abs( difference[i] )

#print difference

exch = sum_abs_d // 2

if sum_d != 0:
	print -1
	exit(0)

if exch == 0:
	print -1
	exit(0)

if exch > N:
	print -1
	exit(0)

print exch

import sys,os
from io import BytesIO, IOBase
import collections,itertools,bisect,heapq,math,string
# region fastio

BUFSIZE = 8192

BUFSIZE = 8192

class FastIO(IOBase):
    newlines = 0

    def __init__(self, file):
        self._fd = file.fileno()
        self.buffer = BytesIO()
        self.writable = "x" in file.mode or "r" not in file.mode
        self.write = self.buffer.write if self.writable else None

    def read(self):
        while True:
            b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
            if not b:
                break
            ptr = self.buffer.tell()
            self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr)
        self.newlines = 0
        return self.buffer.read()

    def readline(self):
        while self.newlines == 0:
            b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
            self.newlines = b.count(b"\n") + (not b)
            ptr = self.buffer.tell()
            self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr)
        self.newlines -= 1
        return self.buffer.readline()

    def flush(self):
        if self.writable:
            os.write(self._fd, self.buffer.getvalue())
            self.buffer.truncate(0), self.buffer.seek(0)

class IOWrapper(IOBase):
    def __init__(self, file):
        self.buffer = FastIO(file)
        self.flush = self.buffer.flush
        self.writable = self.buffer.writable
        self.write = lambda s: self.buffer.write(s.encode("ascii"))
        self.read = lambda: self.buffer.read().decode("ascii")
        self.readline = lambda: self.buffer.readline().decode("ascii")

sys.stdin, sys.stdout = IOWrapper(sys.stdin), IOWrapper(sys.stdout)
input = lambda: sys.stdin.readline().rstrip("\r\n")
# ------------------------------
def main():
    n = int(input())
    a = list(map(int, input().split()))
    b = list(map(int, input().split()))
    c = {}
    d = {}
    for i in range(n):
        if a[i] in c:
            c[a[i]] += 1
        else:
            c[a[i]] = 1
    for i in range(n):
        if b[i] in d:
            d[b[i]] += 1
        else:
            d[b[i]] = 1
    #print(c)
    #print(d)
    e = 0
    l = 0
    #g = []
    #h = []
    k = []
    m = 0
    if n == 1:
        if a == b:
            print(0)
        else:
            print(-1)
    else:
        for i in c:
            if i in d:
                m += 1
                if c[i] == d[i]:
                    continue
                else:
                    e = abs(c[i]+d[i])
                    if e%2 == 0:
                        l = e//2
                        k.append(l//2)
                    #g.append(e//2)
            else:
                e = abs(c[i])
                if e%2 == 0:
                    l = e//2
                    k.append(l)
        m = m//2
        g = sum(k)-m
        if g == 0:
            g = -1
        print(g)
if __name__ == "__main__":
    main()

from sys import stdin, stdout

class1 = []
class2 = []

data_length = int(stdin.readline())

c1 = map(int, stdin.readline().split())
c2 = map(int, stdin.readline().split())

c1d = {}
c2d = {}

for mark in c1:
    c1d[mark] = c1d.get(mark, 0) + 1

for mark in c2:
    c2d[mark] = c2d.get(mark, 0) + 1

perm = 0

for mark in range(1, 6):
    if (c1d.get(mark, 0) + c2d.get(mark, 0)) % 2 == 1:
        stdout.write('-1' + '\n')

diff = 0
for mark in range(1, 6):
    diff += abs(c1d.get(mark, 0) - c2d.get(mark, 0))

stdout.write(str(diff//4))

from collections import Counter
n = int(input())
class_a = [int(x) for x in input().split()]
class_b = [int(x) for x in input().split()]
A = Counter(class_a)
B = Counter(class_b)
delta = 0
for grade in range(1, 6):
	if (A[grade] + B[grade]) % 2 == 1:
		print(-1)
		exit()
	delta += abs(A[grade] - B[grade])
print(delta / 2)

#!/usr/bin/env python

n=int(input())
A=map(str,raw_input().split(' '))
B=map(str,raw_input().split(' '))

NA=[0]*5
NB=[0]*5
final=[0]*5
for i in range(5):
    NA[i]=A.count(str(i+1))
    NB[i]=B.count(str(i+1))
    print NA[i]
    print NB[i]
    print "-----"

result=0
for i in range(5):
    if (NA[i]+NB[i])%2==1:
        result=-1
        break
    else:
        final[i]=(NA[i]+NB[i])/2
        print final[i]
total=0
for i in range(5):
    total+=abs(NA[i]-final[i])

print "answer"
if result==-1:
    print result
else:
    print total/2

n = int(input())
x1 = list(map(int, input().split()))
x2 = list(map(int, input().split()))
ans = 0
count1 = [0,0,0,0,0,0]
count2 = [0,0,0,0,0,0]
flag = True
for i in range(1, 6):
 s = x1.count(i) + x2.count(i)
 count1[i] = x1.count(i)
 count2[i] = x2.count(i)
 if(s%2==1):
  flag = False
  break

if(flag):
 x1.sort()
 x2.sort()
 for i in range(1, 6):
  if(count1[i]==count2[i]):
   for j in range(count1[i]):
    x1.remove(i)
    x2.remove(i)
 l = len(x1)
 for i in range(l):
  if(x1[i] != x2[i]):
   ans +=1
 print(ans//2)
else:
 print(-1)

n=input()
a=list(map(int,input().split()))
b=list(map(int,input().split()))
ans=(abs(a.count(1)-b.count(1))+abs(a.count(2)-b.count(2))+abs(a.count(3)-b.count(3))+abs(a.count(4)-b.count(4))+abs(a.count(5)-b.count(5)))/4
if ans==int(ans):
    print(ans)
else:
    print("-1")

import sys
n=int(sys.stdin.readline())
A=list(map(int,sys.stdin.readline().split()))
B=list(map(int,sys.stdin.readline().split()))
l1=[0]*6
l2=[0]*6
for i in range(n):
    l1[A[i]]+=1
    l2[B[i]]+=1
flag=True
ans=0
for i in range(1,6):
    x=l1[i]+l2[i]
    if x%2!=0:
        flag=False
        break
    ans+=abs(x-l1[i])
if flag:
    print(ans//2)
else:
    print(-1)

import sys
from math import ceil
read=lambda:sys.stdin.readline().strip()
write=lambda x:sys.stdout.write(x+"\n")
N=int(read())
SA=list(map(int, read().split()));
SB=list(map(int, read().split()));
arrA = [0 for _ in range(5)]
arrB = [0 for _ in range(5)]
for i in range(N):
    arrA[SA[i]-1] += 1
    arrB[SB[i]-1] += 1
result = 0
for i in range(5):
    s = arrA[i] + arrB[i]
    diff = abs(arrA[i]-arrB[i])
    diff /= 2
    if s % 2:
        result = -1
        break
    result += diff

if result > 0:
    result = int(ceil(result/2))

write(str(result))

import sys

n = int(sys.stdin.readline())
a = list(map(int, sys.stdin.readline().split()))
b = list(map(int, sys.stdin.readline().split()))
ans = 0

am = [0] * 5
bm = [0] * 5

for i in a:
    am[i - 1] += 1
for i in b:
    bm[i - 1] += 1

for i in range(5):
    if am[i] != bm[i]:
        ans += abs(am[i] - bm[i]) // 2

print(ans // 2)

n = int(raw_input())
A = map(int, raw_input().split())
B = map(int, raw_input().split())

cant_intercambios = 0
dica = {}
for a in A:
  if a not in dica:
    dica[a] = 0
  dica[a] += 1

dicb = {}
for b in B:
  if b not in dicb:
    dicb[b] = 0
  dicb[b] += 1

print dica, dicb

for nota in dica:
  if dica[nota] % 2 == 0:
    if dicb[nota] % 2 == 0:
      cant_intercambios += (abs(dicb[nota] - dica[nota])) / 2
    else:
      print -1
      break
  else:
    if dicb[nota] % 2 != 0:
      cant_intercambios += (abs(dicb[nota] - dica[nota])) / 2
    else:
      print -1
      break

print cant_intercambios / 2

n = int(input())
a = [int(x) for x in input().split(' ')]
b = [int(x) for x in input().split(' ')]

a_dict = {i: 0 for i in range(1, 6)}
b_dict = {i: 0 for i in range(1, 6)}

for s in a:
    if s in a_dict:
        a_dict[s] += 1
    else:
        a_dict[s] = 1

for t in b:
    if t in b_dict:
        b_dict[t] += 1
    else:
        b_dict[t] = 1
ans = 0
for i in range(1, 6):
    if a_dict[i] + b_dict[i] % 2 == 1:
        ans = -2
    else:
        ans += abs(a_dict[i] - b_dict[i]) // 2

ans = ans // 2
print(ans)

n = int(input())
a = input()
b = input()
w = 0
s = 0

leva = []
levb = []

A = [int(s) for s in a.split(' ')]
B = [int(s) for s in b.split(' ')]

for k in range(5):
    leva.append(0)
    levb.append(0)

    for i in range(n):
        if A[i] == k+1:
            leva[k] += 1
        if B[i] == k+1:
            levb[k] += 1

for i in range(5):
    w += (leva[i] - levb[i])/2
    s += abs((leva[i] - levb[i])/4)

if w == 0 and s % 1 ==0:
    print(int(s))
else:
    print(-1)

n = int(raw_input())
a = map(int, raw_input().strip().split(' '))
b = map(int, raw_input().strip().split(' '))

countA = [0 for i in xrange(6)]
countB = [0 for i in xrange(6)]
for i in a:
    countA[i] += 1

for i in b:
    countB[i] += 1

ans = 0
for i in xrange(6):
    ans += abs(countA[i] - countB[i])

if ans % 4 == 0:
    print ans / 4
else:
    print -1

n = int(input())
a = list(map(int, input().split()))
b = list(map(int, input().split()))

count = [0 for x in range(100)]

for x in a:
  count[x] += 1
for x in b:
  count[x] -= 1

for x in range(100):
  if count[x] < 0:
    count[x] = abs(count[x])

total = sum(count) // 2
if total % 2 != 0:
  print(-1)
else:
  print(total // 2)

n = int(input())
#m = input().split() #list
#[a, b, c] = [int(x) for x in input().split()]
A = [int(x) for x in input().split()]
B = [int(x) for x in input().split()]

A_grades = [0, 0, 0, 0, 0]
B_grades = [0, 0, 0, 0, 0]

for i in range(0, n):
    A_grades[A[i]-1] += 1
    B_grades[B[i]-1] += 1

#Check if such changes can happen
for i in range(0, 5):
    if (A_grades[i] + B_grades[i]) % 2 != 0:
        print(-1)

dif = 0
for i in range(0, 5):
    dif += abs(A_grades[i]- B_grades[i])

print(dif // 4)

input()
a=[0]*6
for i in[1,-1]:
  for x in map(int,input().split()):a[x]+=i
s=sum(abs(x)for x in a)
print([s//4,-1][s%4>0])

'''
http://codeforces.com/problemset/problem/779/A
'''

n = int(input())
groupA = list(map(int, input().split()))
groupB = list(map(int, input().split()))

def num_switches(n, groupA, groupB):
    diff = [0, 0, 0, 0, 0]
    for score in range(1, 6):
        if abs(groupA.count(score) - groupB.count(score)) % 2 == 1:
            return -1
        else:
            diff[score - 1] = abs(groupA.count(score) - groupB.count(score))
    if sum(diff) % 4 != 0:
        return -1
    else:
        return sum(diff) / 4

print(num_switches(n, groupA, groupB))

def pupils(lst1, lst2):
    count = 0
    for i in range(1, 6):
        if (lst1[i] + lst2[i]) % 2 != 0:
            return -1
        else:
            t = abs(lst1[i] - lst2[i]) // 2
            count += t
    if count % 2 != 0:
        return -1
    return count // 2

n = int(input())
a = [int(j) for j in input().split()]
b = [int(z) for z in input().split()]
print(pupils(a, b))

x = int(input())
a = list(map(int,input().split()))
b = list(map(int,input().split()))
s = a + b
t = list(set(s))
k = 0
k1 = 0
flag = 0
d = {}
for i in range(len(t)):
	r = a.count(t[i])
	r1 = b.count(t[i])
	if (r-r1)%2 == 1 or (r1-r)%2 == 1:
		print(-1)
		k = 1
	elif r > r1:
		k = k + r - r1
	else:
		k1 = k1 + r1 - r
if k%2 == 0 and k == k1 and flag == 0:
	print(k//2)
elif flag == 0:
	print(-1)

n = int(raw_input())
a = map(int, raw_input().strip().split(' '))
b = map(int, raw_input().strip().split(' '))

countA = [0 for i in xrange(6)]
countB = [0 for i in xrange(6)]
for i in a:
    countA[i] += 1

for i in b:
    countB[i] += 1

ans = 0
for i in xrange(6):
    if countA[i] + countB[i] % 2 == 1:
        print -1
        exit(0)
    diff = abs(countA[i] - countB[i])
    ans += diff / 2

print ans / 2

n=int(input())
l=list(map(int,input().split()))
l1=list(map(int,input().split()))
k=0
p=[]
p1=[]
for i in range(5) :
    p.append(l.count(i+1))
    p1.append(l1.count(i+1))
c=0
while p!=p1 and c==0 :
    for i in range(5) :

        if p[i]!=p1[i] :

            if p[i]<p1[i] :
                p[i]=p[i]+1
                p1[i]=p1[i]-1
                if abs(p[i]-p1[i])%2!=0 :
                    c=1
                    break
            else :
                if p[i]>p1[i] :
                    p[i]=p[i]-1
                    p1[i]=p1[i]+1
                    if abs(p[i]-p1[i])%2!=0 :
                        c=1
                        break

                for j in range(i+1,5) :
                    if p[j]!=p1[j] :
                        if p[j]!=p1[j] :
                            if p[j]<p1[j] :
                                p[j]=p[j]+1
                                p1[j]=p1[j]-1
                                if abs(p[j]-p1[j])%2!=0 :
                                    c=1
                                    break
                            else :
                                if p[j]>p1[j] :
                                    p[j]=p[j]-1
                                    p1[j]=p1[j]+1
                                    if abs(p[j]-p1[j])%2!=0 :
                                        c=1
                                        break
    k=k+1
if c==0 :
    print(k)
else :
    print(-1)

import sys
n =int(input())
a =list(map(int,input().split()))
b =list(map(int,input().split()))
special = 0
lcng =rcng=0
for j in range(1,6):
    l = a.count(j)
    r = b.count(j)

    if(l != r):
        if((l == 1 and r == 0) or (r == 1 and l == 0)):
            special = 1
        elif(l > r and special != 1):
            lcng += int(l -((l + r)/2))
        else:
            rcng += int(r -((l + r)/2))

if(lcng != rcng or special == 1):
    print("-1")
else:
    print(lcng)

n = input()
f = list(map(str, input().split()))
s = list(map(str, input().split()))

if abs(f.count('1')-s.count('1'))%2==0 and abs(f.count('2')-s.count('2'))%2==0 and abs(f.count('3')-s.count('3'))%2==0 and abs(f.count('4')-s.count('4'))%2==0 and abs(f.count('5')-s.count('5'))%2==0 :
	print(int(abs((f.count('1')-s.count('1')) + abs(f.count('2')-s.count('2')) + abs(f.count('3')-s.count('3')) + abs(f.count('4')-s.count('4')) + abs(f.count('5')-s.count('5')))/4))
else :
	print(-1)

from sys import stdin
n = int(stdin.readline())
a = map(int,stdin.readline().split())
b = map(int,stdin.readline().split())
fir = {}
sec = {}
tot = {}
for i in a:
    fir[i] = fir.get(i,0)+1
    tot[i] = tot.get(i,0) + 1
for i in b:
    sec[i] = sec.get(i,0) + 1
    tot[i] = tot.get(i,0) + 1
valid = 1
for i in xrange(1,6):
    if tot.get(i,0)%2:
        valid = 0
ans = -1
if valid:
    cur = 0
    for i in fir:
        cur += (tot.get(i,0) - fir.get(i,0))/2
    ans = cur
print ans

steps = 0

n = int(input())
Ag = {}
Bg = {}
s = 0

for i in range(1, 6):
    Ag[i] = 0
    Bg[i] = 0

for x in map(int, input().split()):
    Ag[x] += 1

for x in map(int, input().split()):
    Bg[x] += 1

for i in range(1,6):
    if Ag[i] + Bg[i] % 2 == 1:
        print(-1)
        exit(0)
    s += abs(Ag[i] - Bg[i])

print(s // 4)

n=int(input())
a=list(map(int, input().split()))
b=list(map(int, input().split()))
for i in range(1,6):
    if a.count(i)+b.count(i)%2==1:
        print(-1)
        exit()
ans=0
for i in range(1,6):
    ans+=abs(a.count(i)-b.count(i))
print(ans//4)

import sys

steps = 0

n = int(input())
Ag = {}
Bg = {}
s = 0

for i in range(1, 6):
    Ag[i] = 0
    Bg[i] = 0

for x in map(int, input().split()):
    Ag[x] += 1

for x in map(int, input().split()):
    Bg[x] += 1

for i in range(1,6):
    if Ag[i] + Bg[i] % 2 == 1:
        print(-1)
        sys.exit(0)
    s += abs(Ag[i] - Bg[i])

print(s / 4)

n = input()

a = map(int, raw_input().split())

b = map(int, raw_input().split())

da = {}
db = {}
for i in xrange(1,6):
    da[i] = a.count(i)
    db[i] = b.count(i)

c = 0
for i in xrange(1,6):
    if da[i]==db[i]:
        pass
    else:
        c+=abs(da[i]-db[i])
if c%4!=0:
    print -1
else:
    print c/4

from collections import Counter

n = int(input())
a = list(map(int, input().split()))
b = list(map(int, input().split()))

ca = Counter(a)
cb = Counter(b)

def solve():
    ans = 0
    balance = {}

    for mark in range(1, 6):
        c1 = ca.get(mark, 0)
        c2 = cb.get(mark, 0)
        s = c1 + c2
        if s % 2 != 0:
            return -1
        balance[mark] = c1 - (s / 2)

    if sum(balance.values()) != 0:
        return -1

    return sum(map(abs, balance.values())) / 2

print (solve())

import math

a = raw_input()
a = int(a)

b = raw_input()
c = raw_input()

b = b.split()
c = c.split()

b = map(int, b)
c = map(int, c)

count1 = 0
count2 = 0
count3 = 0
count4 = 0
count5 = 0
bount1 = 0
bount2 = 0
bount3 = 0
bount4 = 0
bount5 = 0

for i in range(a):
    if b[i] == 1:
        bount1 += 1
    elif b[i] == 2:
        bount2 += 1
    elif b[i] == 3:
        bount3 += 1
    elif b[i] == 4:
        bount4 += 1
    elif b[i] == 5:
        bount5 += 1

for i in range(a):
    if c[i] == 1:
        count1 += 1
    elif c[i] == 2:
        count2 += 1
    elif c[i] == 3:
        count3 += 1
    elif c[i] == 4:
        count4 += 1
    elif c[i] == 5:
        count5 += 1

if bount1 + count1 % 2 == 1:
    print -1
elif bount2 + count2 % 2 == 1:
    print -1
elif bount3 + count3 % 2 == 1:
    print -1
elif bount4 + count4 % 2 == 1:
    print -1
elif bount5 + count5 % 2 == 1:
    print -1
else:
    count = 0
    if bount1 > (bount1 + count1)/2:
        count += bount1 - (bount1 + count1)/2
    if bount2 > (bount2 + count2)/2:
        count += bount2 - (bount2 + count2)/2
    if bount3 > (bount3 + count3)/2:
        count += bount3 - (bount3 + count3)/2
    if bount4 > (bount4 + count4)/2:
        count += bount4 - (bount4 + count4)/2
    if bount5 > (bount5 + count5)/2:
        count += bount5 - (bount5 + count5)/2
    print count

import sys

N = sys.stdin.readline()
A = map(int, sys.stdin.readline().split())
B = map(int, sys.stdin.readline().split())
a_maps = {}
b_maps = {}
all_keys = set()
total_diff = 0
for idx in range(len(A)):
    if A[idx] in a_maps:
        a_maps[A[idx]] += 1
    else:
        a_maps[A[idx]] = 1
    all_keys.add(A[idx])
    if B[idx] in b_maps:
        b_maps[B[idx]] += 1
    else:
        b_maps[B[idx]] = 1
    all_keys.add(B[idx])

total_diff = 0
for key in sorted(list(all_keys)):
    a = a_maps[key] if key in a_maps else 0
    b = b_maps[key] if key in b_maps else 0
    diff = a-b if a > b else b-a
    total_diff += diff
ans = total_diff / 4 if total_diff % 4 == 0 else -1
print ans

from collections import Counter

n = int(raw_input())
a = map(int, raw_input().split(' '))
b = map(int, raw_input().split(' '))

ca = Counter(a)
cb = Counter(b)

def solve():
    ans = 0
    balance = {}

    for mark in xrange(1, 6):
        c1 = ca.get(mark, 0)
        c2 = cb.get(mark, 0)
        s = c1 + c2
        if s % 2 != 0:
            return -1
        balance[mark] = (s / 2) * (-1 if c1 > c2 else 1)

    for mark1 in xrange(1, 5):
        if balance[mark1] == 0:
            continue
        for mark2 in xrange(mark1, 6):
            if balance[mark2] == -balance[mark1]:
                ans += abs(balance[mark1])
                balance[mark1] = balance[mark2] = 0
                break

    return ans

print solve()

# import sys
# sys.stdin=open("input.in",'r')
# sys.stdout=open("out.out",'w')
n=int(input())
a=list(map(int,input().split()))
b=list(map(int,input().split()))
c=[0,0,0,0,0]
for i in a:
	c[i-1]+=1
for j in b:
	c[j-1]-=1
s=0
for i in c:
	s+=abs(i)
if s%2==0:
	x=s//2
	print(x//2)
else:
	print(-1)

from collections import Counter

n = int(input())
a = input().split(' ')
b = input().split(' ')
aa = Counter()
bb = Counter()
for x in aa:
    aa[x] += 1
for x in bb:
    bb[x] += 1
possible = True
mm = Counter()
for x in ('1', '2', '3', '4', '5'):
    if (aa[x] + bb[x]) % 2 != 0:
        possible = False
    else:
        mm[x] = (aa[x] + bb[x]) / 2
if not possible:
    print('-1')
else:
    print(sum(abs(aa[x] - mm[x]) for x in ('1', '2', '3', '4', '5')))

def pupils(lst1, lst2):
    count = 0
    for i in range(len(lst1)):
        t = abs(lst1[i] - lst2[i])
        if t % 2 == 1:
            return -1
        count += t // 2
    return count // 2

n = int(input())
a = [int(j) for j in input().split()]
b = [int(z) for z in input().split()]
print(pupils(a, b))

n = int(input())
a = list(map(int, input().split()))
b = list(map(int, input().split()))
c = [0,0,0,0,0]
for i in a:
    c[i - 1] += 1
for j in b:
    c[j - 1] -= 1
c = [abs(i) for i in c]
import sys
for i in c:
    if i % 2:
        print(-1)
        sys.exit(0)
print(sum(c) / 2)

'''
http://codeforces.com/problemset/problem/779/A
'''

n = int(input())
groupA = list(map(int, input().split()))
groupB = list(map(int, input().split()))

def num_switches(n, groupA, groupB):
    #initialize number of switches needed
    switches = 0
    #loops through all possible scores
    for score in range(1, 6):
        freqA = groupA.count(score)
        freqB = groupB.count(score)
        freq_diff = freqA - freqB
        #checks if the desired destribution is possible
        if freq_diff % 2 == 1:
            return -1
        while freq_diff != 0:
            if freqA > freqB:
                #switches two values from A and B
                for i in range(n):
                    if groupB[i] > score:
                        switch = i
                switches += 1
                groupA[groupA.index(score)], groupB[switch] = groupB[switch], groupA[groupA.index(score)]
            else:
                #switches two values from A and B
                for i in range(n):
                    if groupA[i] > score:
                        switch = i
                switches += 1
                groupB[groupB.index(score)], groupA[switch] = groupA[switch], groupB[groupB.index(score)]
            #recomputes frequencies of the score in groupA and groupB
            freqA = groupA.count(score)
            freqB = groupB.count(score)
            freq_diff = freqA - freqB
    return switches

print(num_switches(n, groupA, groupB))

import sys
n =int(input())
a =list(map(int,input().split()))
b =list(map(int,input().split()))
special = 0
lcng =rcng=0
for j in range(1,6):
    l = a.count(j)
    r = b.count(j)

    if(l != r):
        if((l == 1 and r == 0) or (r == 1 and l == 0)):
            special = 1
        elif(l > r and special != 1):
            lcng += int(l -((l + r)/2))
        else:
            rcng += int(r -((l + r)/2))

if(lcng != rcng or special == 1):
    print("-1")
else:
    print(lcng)

import collections
n = int(input())
a = list(map(int, input().split()))
b = list(map(int, input().split()))
acnt = collections.Counter(a)
abcnt = collections.Counter(a+b)
ans = 0
for k, v in abcnt.items():
    if v & 1:
        ans = -1
        break
    ans += (v - acnt[k]) // 2
print(ans)

import sys
n = int(input())
a_group = list(map(int,input().split()))
b_group = list(map(int,input().split()))

cnt_a = cnt_b = 0
for i in range(1,6):
    c1 = a_group.count(i)
    c2 = b_group.count(i)
    if c1 > c2:
         cnt_a += c1 - (int((c1+c2)/2))
    elif c1 < c2:
        cnt_b += c2 - (int(c1+c2)/2)

if cnt_a != cnt_b:
    print('-1')
else:
    print(cnt_a)

n=input()
a=list(map(int,input().split()))
b=list(map(int,input().split()))
ans=(abs(a.count(1)-b.count(1))+abs(a.count(2)-b.count(2))+abs(a.count(3)-b.count(3))+abs(a.count(4)-b.count(4))+abs(a.count(5)-b.count(5)))/4
if ans==int(ans):
    print(int(ans))
else:
    print("-1")

n=int(input())
perfsA,perfsB=[0,0,0,0,0],[0,0,0,0,0]
list1,list2=input().split(),input().split()
for num in list1:
    num=int(num)
    perfsA[num-1]+=1
for num in list2:
    num=int(num)
    perfsB[num-1]+=1
swips=0
for i in range(0,5):
    if abs(perfsA[i]-perfsB[i])%2==1:
        swips=-1
        break
    swips+=abs(perfsB[i]-perfsA[i])/2
print(int(swips))

from sys  import stdin,stdout
from collections  import *
from math import ceil, floor , log, gcd
st=lambda:list(stdin.readline().strip())
li=lambda:list(map(int,stdin.readline().split()))
mp=lambda:map(int,stdin.readline().split())
inp=lambda:int(stdin.readline())
pr=lambda n: stdout.write(str(n)+"\n")

mod=1000000007
INF=float('inf')

def solve():
    n=inp()
    l=li()
    k=li()
    d=Counter(l)
    dd=Counter(l)
    ddd=Counter(l+k)
    for i in ddd:
        if ddd[i]&1:
            pr(-1)
            return
    ans=0
    for i in d:
        ans+=d[i]//2
    for i in dd:
        ans+=dd[i]//2
    pr(ans//2)

for _ in range(1):
    solve()

x = int(input())
a = list(map(int,input().split()))
b = list(map(int,input().split()))
s = a + b
t = list(set(s))
k = 0
k1 = 0
flag = 0
d = {}
for i in range(len(t)):
	r = a.count(t[i])
	r1 = b.count(t[i])
	if (r-r1)%2 == 1 or (r1-r)%2 == 1:
		print(-1)
		k = 1
	elif r > r1:
		k = k + r - r1
	else:
		k1 = k1 + r1 - r
if k%2 == 0 and k == k1 and flag == 0:
	print(k//2)
elif flag == 0:
	print(-1)

import sys

def solve(N, A_ranks, B_ranks):
    A = {}
    B = {}
    for rank in A_ranks:
        if rank in A:
            A[rank] += 1
        else:
            A[rank] = 1
    for rank in B_ranks:
        if rank in B:
            B[rank] += 1
        else:
            B[rank] = 1

    diffs = 0
    moves = 0
    total_keys = set(A.keys()) | set(B.keys())
    for key in total_keys:
        a_val = A[key] if key in A else 0
        b_val = B[key] if key in B else 0
        if a_val > b_val:
            A[key] = a_val - b_val
            B[key] = 0
        elif b_val > a_val:
            B[key] = b_val - a_val
            A[key] = 0

    a_count = 0
    b_count = 0
    for key in total_keys:
        a_val = A[key] if key in A else 0
        b_val = B[key] if key in B else 0
        if a_val > 0:
            if a_val % 2 == 0:
                a_count += a_val / 2
            else:
                return -1
        elif b_val > 0:
            if b_val % 2 == 0:
                b_count += b_val / 2
            else:
                return -1
    if a_count != b_count:
        return -1
    else:
        return a_count

if __name__ == "__main__":
    N = int(sys.stdin.readline())
    A = map(int, sys.stdin.readline().split())
    B = map(int, sys.stdin.readline().split())
    print solve(N, A, B)

n = int(input())
a = list(map(int, input().split()))
b = list(map(int, input().split()))

count = [0 for x in range(100)]

for x in a:
  count[x] += 1
for x in b:
  count[x] -= 1

for x in range(100):
  if count[x] < 0:
    count[x] = abs(count[x])

total = sum(count) // 2
if total % 2 != 0:
  print(-1)
else:
  print(total // 2)

import math

a = raw_input()
a = int(a)

b = raw_input()
c = raw_input()

b = b.split()
c = c.split()

b = map(int, b)
c = map(int, c)

count1 = 0
count2 = 0
count3 = 0
count4 = 0
count5 = 0
bount1 = 0
bount2 = 0
bount3 = 0
bount4 = 0
bount5 = 0

for i in range(a):
    if b[i] == 1:
        bount1 += 1
    elif b[i] == 2:
        bount2 += 1
    elif b[i] == 3:
        bount3 += 1
    elif b[i] == 4:
        bount4 += 1
    elif b[i] == 5:
        bount5 += 1

for i in range(a):
    if c[i] == 1:
        count1 += 1
    elif c[i] == 2:
        count2 += 1
    elif c[i] == 3:
        count3 += 1
    elif c[i] == 4:
        count4 += 1
    elif b[i] == 5:
        count5 += 1

if bount1 + count1 % 2 == 1:
    print -1
elif bount2 + count2 % 2 == 1:
    print -1
elif bount3 + count3 % 2 == 1:
    print -1
elif bount4 + count4 % 2 == 1:
    print -1
elif bount5 + count5 % 2 == 1:
    print -1
else:
    count = 0
    if bount1 > (bount1 + count1)/2:
        count += bount1 - (bount1 + count1)/2
    if bount2 > (bount2 + count2)/2:
        count += bount2 - (bount2 + count2)/2
    if bount3 > (bount3 + count3)/2:
        count += bount3 - (bount3 + count3)/2
    if bount4 > (bount4 + count4)/2:
        count += bount4 - (bount4 + count4)/2
    if bount5 > (bount5 + count5)/2:
        count += bount5 - (bount5 + count5)/2
    print count

n=int(input())
a=list(map(int,input().split()))
b=list(map(int,input().split()))
d=dict()
for i in a :
      if i in d:
            d[i]+=1
      else:
            d[i]=1
for i in b :
      if i in d:
            d[i]+=1
      else:
            d[i]=1
val=list(d.values())
x=True
for i in val :
      if i%2!=0:
            x=False
            break
s=0
if x:
      if len(val)==1:
            print(0)
      else:
            for i in list(set(a)):
                  s=max(s+a.count(i)-(d[i]//2),1)
            print(s)
else:
      print(-1)

import sys,os
from io import BytesIO, IOBase
import collections,itertools,bisect,heapq,math,string
# region fastio

BUFSIZE = 8192

BUFSIZE = 8192

class FastIO(IOBase):
    newlines = 0

    def __init__(self, file):
        self._fd = file.fileno()
        self.buffer = BytesIO()
        self.writable = "x" in file.mode or "r" not in file.mode
        self.write = self.buffer.write if self.writable else None

    def read(self):
        while True:
            b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
            if not b:
                break
            ptr = self.buffer.tell()
            self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr)
        self.newlines = 0
        return self.buffer.read()

    def readline(self):
        while self.newlines == 0:
            b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
            self.newlines = b.count(b"\n") + (not b)
            ptr = self.buffer.tell()
            self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr)
        self.newlines -= 1
        return self.buffer.readline()

    def flush(self):
        if self.writable:
            os.write(self._fd, self.buffer.getvalue())
            self.buffer.truncate(0), self.buffer.seek(0)

class IOWrapper(IOBase):
    def __init__(self, file):
        self.buffer = FastIO(file)
        self.flush = self.buffer.flush
        self.writable = self.buffer.writable
        self.write = lambda s: self.buffer.write(s.encode("ascii"))
        self.read = lambda: self.buffer.read().decode("ascii")
        self.readline = lambda: self.buffer.readline().decode("ascii")

sys.stdin, sys.stdout = IOWrapper(sys.stdin), IOWrapper(sys.stdout)
input = lambda: sys.stdin.readline().rstrip("\r\n")
# ------------------------------
def main():
    n = int(input())
    a = list(map(int, input().split()))
    b = list(map(int, input().split()))
    c = {}
    d = {}
    for i in range(n):
        if a[i] in c:
            c[a[i]] += 1
        else:
            c[a[i]] = 1
    for i in range(n):
        if b[i] in d:
            d[b[i]] += 1
        else:
            d[b[i]] = 1
    #print(c)
    #print(d)
    e = 0
    g = 0
    h = 0
    m = 0
    o = 0
    for i in c:
        if i in d:
            #e.append(i)
            if c[i] == d[i]:
                continue
            else:
                #m += 1
                if c[i] > d[i]:
                    g = abs(c[i] - d[i])
                else:
                    g = 0
                if(g%2 == 0):
                    h += g//2
                else:
                    h = -1
                    break
        else:
            g = c[i]
            if(g%2 == 0):
                e += g//2
            else:
                e = -1
                break
    for i in d:
        if i not in c:
            g = d[i]
            if(g%2 == 0):
                o += g//2
            else:
                o = -1

    #print(h,e,m,o)
    if(h == -1 or e == -1 or o == -1):
        e = -1
    else:
        #if(h > 0 and m > 0):
         #   h = h//m
        if e+h > o:
            e = h+e-o
        else:
            e = h+e
    print(e)

if __name__ == "__main__":
    main()

n = input()

a = map(int, raw_input().split())

b = map(int, raw_input().split())

da = {}
db = {}
for i in xrange(1,6):
    da[i] = a.count(i)
    db[i] = b.count(i)

c = 0
for i in xrange(1,6):
    if da[i]==db[i]:
        pass
    else:
        c+=abs(da[i]-db[i])
if c%4!=0:
    print -1
else:
    print c/4

x = int(input())
a = list(map(int,input().split()))
b = list(map(int,input().split()))
s = a + b
t = list(set(s))
k = 0
k1 = 0
d = {}
for i in range(len(t)):
	r = a.count(t[i])
	r1 = b.count(t[i])
	if (r-r1)%2 == 1 or (r1-r)%2 == 1:
		print(-1)
	elif r > r1:
		k = k + r - r1
	else:
		k1 = k1 + r1 - r
if k%2 == 0 and k == k1:
	print(k//2)
else:
	print(-1)

n = int(input())
cnt = [0]*5
A = [int(i) - 1 for i in input().split()]
B = [int(i) - 1 for i in input().split()]
for i in A:
    cnt[i] += 1
for i in B:
    cnt[i] -= 1
res_4 = sum(abs(i) for i in cnt)
if res_4 % 4 == 0:
    print(res_4 // 4)
else:
    print(-1)

# 19:39
# Перераспределение учеников. Вход - оценки. Выход - количество перемещений
n = int(input())
class_A = [int(x) for x in input().split(' ')]
class_B = [int(x) for x in input().split(' ')]
cnt = [0 for x in range(1, 6)]

def main():
	for mark in class_A:
		cnt[mark - 1] += 1
	for mark in class_B:
		cnt[mark - 1] -= 1
	print(cnt)
	for mark in cnt:
		if mark % 2 != 0:
			return -1
	c = 0
	for mark in cnt:
		c += abs(mark)
	return c // 4

print(main())

from sys import stdin, stdout

class1 = []
class2 = []

data_length = int(stdin.readline())

c1 = map(int, stdin.readline().split())
c2 = map(int, stdin.readline().split())

c1d = {}
c2d = {}

for mark in c1:
    c1d[mark] = c1d.get(mark, 0) + 1

for mark in c2:
    c2d[mark] = c2d.get(mark, 0) + 1

perm = 0

for mark in range(1, 6):
    if (c1d.get(mark, 0) + c2d.get(mark, 0)) % 2 == 1:
        stdout.write('-1' + '\n')

diff = 0
for mark in range(1, 6):
    diff += abs(c1d.get(mark, 0) - c2d.get(mark, 0))

stdout.write(str(diff//4)+'\n')

n = int(input())
Sum = 0
classA = list(map(int,input().split()))
classB =list(map(int,input().split()))
w=False
for i in range(1,6) :
    if classA.count(i)+classB.count(i) %2 == 1:
        w=True
        break

    else:
        Sum += abs(classA.count(i) - classB.count(i))

if w:
    print (-1)

else:
    print(Sum/4)

##n = int(input())
##a = list(map(int, input().split()))
##print(' '.join(map(str, res)))

n = int(input())
a = list(map(int, input().split()))
b = list(map(int, input().split()))

ha = [0 for i in range(5)]
hb = [0 for i in range(5)]
for i in range(n):
    ha[a[i]-1] += 1
    hb[b[i]-1] += 1

res = 0
used = [0 for i in range(5)]
for i in range(5):
    if used[i] == 0:
        for j in range(i+1, 5):
            if used[j] == 0:
                if ha[i] == hb[j] and hb[i] == ha[j] and (ha[i]+hb[i])%2 == 0:
                    res += abs(ha[i]-(ha[i]+hb[i])//2)
                    used[i] = 1
                    used[j] = 1
                    break

for i in range(5):
    if used[i] == 0 and ha[i] != hb[i]:
        print('-1')
        exit(0)
print(res)

n = int(input())
a = input()
b = input()
w = 0
s = 0

leva = []
levb = []

A = [int(s) for s in a.split()]
B = [int(s) for s in b.split()]

for k in range(5):
    leva.append(0)
    levb.append(0)

    for i in range(n):
        if A[i] == k+1:
            leva[k] += 1
        if B[i] == k+1:
            levb[k] += 1

for i in range(5):
    w += (leva[i] - levb[i])
    s += abs((leva[i] - levb[i])/4)

if w == 0 and s % 1 == 0:
    print(int(s))
else:
    print(-1)

n = input()
f = list(map(int, input().split()))
s = list(map(int, input().split()))

if f.count('1')-s.count('1')%2==0 and f.count('2')-s.count('2')%2==0 and f.count('3')-s.count('3')%2==0 and f.count('4')-s.count('1')%2==0 and f.count('5')-s.count('5')%2==0 :
	print((abs(f.count('1')-s.count('1')) + abs(f.count('2')-s.count('2')) + abs(f.count('3')-s.count('3')) + abs(f.count('4')-s.count('4')) + abs(f.count('5')-s.count('5')))/4)
else :
	print(-1)

#!/usr/bin/python
# -*- coding: UTF-8 -*-

n = int(raw_input())
l1 = map(int, raw_input().split())
l2 = map(int, raw_input().split())
l1.sort()
l3 = l1 + l2
l4 = []
mark = 0
for x in xrange(1, 6):
    if l3.count(x) % 2 == 0:
        for y in xrange(l3.count(x) / 2):
            l4.append(x)
    else:
        mark = -1
        break
if mark == -1:
    pass
else:
    mark = 0
    l4.sort()
    for x in xrange(n):
        if l4[x] == l1[x]:
            pass
        else:
            mark += 1
print mark

n=int(input())
a=list(map(int,input().split()))
b=list(map(int,input().split()))
d=dict()
for i in a :
      if i in d:
            d[i]+=1
      else:
            d[i]=1
for i in b :
      if i in d:
            d[i]+=1
      else:
            d[i]=1
val=list(d.values())
x=True
for i in val :
      if i%2!=0:
            x=False
            break
s=0
if x:
      for i in list(set(a)):
            s=max(s+a.count(i)-(d[i]//2),1)
      print(s)
else:
      print(-1)

import sys

n = int(sys.stdin.readline())
a = list(map(int, sys.stdin.readline().split()))
b = list(map(int, sys.stdin.readline().split()))
ans = 0

am = [0] * 5
bm = [0] * 5

for i in a:
    am[i - 1] += 1
for i in b:
    bm[i - 1] += 1

for i in range(5):
    if am[i] != bm[i]:
        ans += abs(am[i] - bm[i]) // 2

print(ans // 2)

n = int(input())
a = [int(x) for x in input().split(' ')]
b = [int(x) for x in input().split(' ')]

a_dict = {i: 0 for i in range(1, 6)}
b_dict = {i: 0 for i in range(1, 6)}

for s in a:
    if s in a_dict:
        a_dict[s] += 1
    else:
        a_dict[s] = 1

for t in b:
    if t in b_dict:
        b_dict[t] += 1
    else:
        b_dict[t] = 1
ans = 0
for i in range(1, 6):
    if (a_dict[i] + b_dict[i]) % 2 == 1:
        ans = -1
    else:
        ans += abs((a_dict[i] + b_dict[i]) // 2 - a_dict[i])

ans = ans
print(ans)

x = int(input())
a = list(map(int,input().split()))
b = list(map(int,input().split()))
s = a + b
t = list(set(s))
k = 0
k1 = 0
d = {}
for i in range(len(t)):
	r = a.count(t[i])
	r1 = b.count(t[i])
	if r > r1:
		k = k + r - r1
	else:
		k1 = k1 + r1 - r
if k%2 == 0 and k == k1:
	print(k//2)
else:
	print(-1)

def fail():
    print(-1)
    exit()
read = lambda: map(int, input().split())
n = int(input())
a = sorted(read())
b = sorted(read())
for i in range(1, 6):
    if (a.count(i) + b.count(i)) % 2:
        fail()
cnt = 0
while 1:
    flag = False
    for i in range(n):
        if a.count(a[i]) != b.count(a[i]):
            for j in range(n):
                if a.count(b[j]) != b.count(b[j]) and a[i] != b[j]:
                    a[i], b[j] = b[j], a[i]
                    cnt += 1
                    break
        if flag:
            break
    if not flag:
        break
print(cnt)

n = int(input())
a = [int(x) for x in input().split(' ')]
b = [int(x) for x in input().split(' ')]

a_dict = {i: 0 for i in range(1, 6)}
b_dict = {i: 0 for i in range(1, 6)}

for s in a:
    if s in a_dict:
        a_dict[s] += 1
    else:
        a_dict[s] = 1

for t in b:
    if t in b_dict:
        b_dict[t] += 1
    else:
        b_dict[t] = 1
ans = 0
for i in range(1, 6):
    if (a_dict[i] + b_dict[i]) % 2 == 1:
        ans = -2
    else:
        ans += abs(a_dict[i] - b_dict[i]) // 2

ans = ans // 2
print(ans)

n = int(input())

lista = list(map(int,input().split()))
listb = list(map(int,input().split()))

coua = [0]*6
coub = [0]*6

for v in lista:
    coua[v] +=1

for v in listb:
    coub[v] +=1

ok = True
ans = 0
for v in range(1,6):
    sumab = coua[v]+coub[v]
    if(sumab % 2 != 0):
        ok = False
        break
    ans += abs(coua[v]-sumab/2)

if not ok:
    print(-1)
else :
    print(ans//2)

from collections import Counter
n = int(input())
class_a = [int(x) for x in input().split()]
class_b = [int(x) for x in input().split()]
A = Counter(class_a)
B = Counter(class_b)
delta = 0
for grade in range(1, 6):
	if (A[grade] + B[grade]) % 2 == 1:
		print(-1)
		exit()
	delta += abs(A[grade] - B[grade])
print(delta // 2)

import collections
n = int(input())
a = list(map(int, input().split()))
b = list(map(int, input().split()))
acnt = collections.Counter(a)
bcnt = collections.Counter(b)
ans = 0
for x, y in zip(acnt, bcnt):
    if (x+y) & 1:
        ans = -1
        break
    ans += abs(x - y) // 2
print(ans)

n = int(input())
A = list(map(int, input().split()))
B = list(map(int, input().split()))
cnt = [0] * 5
for elem in A:
    cnt[elem - 1] += 1
for elem in B:
    cnt[elem - 1] += 1
bad = 0
for elem in cnt:
    bad += elem % 2
if bad != 0:
    print(-1)
cntA = [0] * 5
cntB = [0] * 5
for elem in A:
    cntA[elem - 1] += 1
for elem in B:
    cntB[elem - 1] += 1
ans = 0
for i in range(5):
    ans += abs(cntA[i] - cntB[i]) // 2
print(ans // 2)

n = input()

a = map(int, raw_input().split())

b = map(int, raw_input().split())

da = {}
db = {}
for i in xrange(1,6):
    da[i] = a.count(i)
    db[i] = b.count(i)

c = 0
for i in xrange(1,6):
    if da[i]==db[i]:
        pass
    else:
        c+=abs(da[i]-db[i])
if c!=0 and c<4:
    print -1
else:
    print c/4

# import sys
# sys.stdin=open("input.in",'r')
# sys.stdout=open("out.out",'w')
n=int(input())
a=list(map(int,input().split()))
b=list(map(int,input().split()))
c=[0,0,0,0,0]
for i in a:
	c[i-1]+=1
for j in b:
	c[j-1]-=1
s=0
for i in c:
	s+=abs(i)
if s%2==0:
	x=s//2
	print(x//2)
else:
	print(-1)

n = int(input())
a = list(map(int,input().split()))
b = list(map(int,input().split()))
c=0
d=0
z=0
for j in range(5):
    for i in range(n):
        if a[i]==j+1:
            c+=1
    for i in range(n):
        if b[i]==j+1:
            d+=1
    if (c+d)%2==0:
        z=-1
        break
    else:
        z+=abs(c-d)//2
print(z)

n = int(input())
classA = list(map(int, input().split()))
classB = list(map(int, input().split()))

a1 = classA.count(1)
b1 = classA.count(2)
c1 = classA.count(3)
d1 = classA.count(4)
e1 = classA.count(5)

a2 = classB.count(1)
b2 = classB.count(2)
c2 = classB.count(3)
d2 = classB.count(4)
e2 = classB.count(5)

C = (abs(a1 - a2) + abs(b1 - b2) + abs(c1 - c2) + abs(d1 - d2) + abs(e1 - e2)) // 2
if C % 2 == 0:
    print(C // 2)
else:
    print(-1)

import sys
n =int(input())
a =list(map(int,input().split()))
b =list(map(int,input().split()))
special = 0
lcng =rcng=0
for j in range(1,6):
    l = a.count(j)
    r = b.count(j)

    if(l != r):
        if((l == 1 and r == 0) or (r == 1 and l == 0)):
            special = 1
        elif(l > r and special != 1):
            lcng += int(l -((l + r)/2))
        else:
            rcng += int(r -((l + r)/2))

if(lcng != rcng or special == 1):
    print("-1")
else:
    print(lcng)

n = int(raw_input())
l1 = [int(x) for x in raw_input().split()]
l2 = [int(x) for x in raw_input().split()]
from collections import defaultdict
h1 = defaultdict(int)
h2 = defaultdict(int)
for x in l1:
    h1[x] += 1
for x in l2:
    h2[x] += 1
difs = 0
for i in xrange(1,6):
    difs += abs(h1[i]-h2[i])

if difs % 4 == 0:
    print difs/4
else :
    print -1

n=int(input())
a=list(map(int,input().split()))
b=list(map(int,input().split()))
d=dict()
for i in a :
      if i in d:
            d[i]+=1
      else:
            d[i]=1
for i in b :
      if i in d:
            d[i]+=1
      else:
            d[i]=1
val=list(d.values())
x=True
for i in val :
      if i%2!=0:
            x=False
            break
s=0
if x:
      for i in list(set(a)):
            s=max(s+a.count(i)-(d[i]//2),1)
      print(s)
else:
      print(-1)

# -*- coding: utf-8 -*-
n = int(input())
c1 = list(map(int, input().split(' ')))
c2 = list(map(int, input().split(' ')))
m1_add = []
m1_rem = []
m2_add = []
m2_rem = []
for i in range(1, 6):
    k1 = c1.count(i)
    k2 = c2.count(i)
    if k1>k2:
        m1_rem.append((k1-k2)//2)
        m2_rem.append(0)
        m1_add.append(0)
        m2_add.append((k1-k2)//2)
    else:
        m1_rem.append(0)
        m2_rem.append((k2-k1)//2)
        m1_add.append((k2-k1)//2)
        m2_add.append(0)
for i in range(5):
    for j in range(m1_add[i]):
        c1.append(i+1)
    for j in range(m2_add[i]):
        c2.append(i+1)
    for j in range(m1_rem[i]):
        c1.remove(i+1)
    for j in range(m2_rem[i]):
        c2.remove(i+1)
if sum([int(i) for i in c1]) == sum([int(i) for i in c2]):
    print(sum(m1_add))
else:
    print(-1)

n=int(input())
ip1=list(map(int,input().split()))
ip2=list(map(int,input().split()))
b=0
for i in range(1,6):
    if (ip1.count(i)+ip2.count(i))%2!=0:
        b=1
        print(-1)
        break
if b==0:
    count=0
    for i in ip1:
        if i in ip2:
            ip1.remove(i)
            ip2.remove(i)
    print(len(ip1)//2)

nb_pupil = int(input())
grp_1 = [int(x) for x in input().split()]
grp_2 = [int(x) for x in input().split()]
changed = 0
ans = -1
for i in range(1, 6):
    grp1 = grp_1.count(i)
    grp2 = grp_2.count(i)
    if not (grp1 + grp2) % 2:
        changed += abs(grp1 - grp2)//2
        ans = 0
    else:
        break
if ans != -1:
    print(changed//2)
else:print(-1)