n = int(eval(input()))

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

l = list(map(int,input().split()))

c = [0,0,0]

for i in l:

    if i <= a:

        c[0] += 1

    elif i > b:

        c[2] += 1

    else:

        c[1] += 1

print((min(c)))
n=int(eval(input()))

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

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

c=[0]*3

for i in p:

       if i <=a:

        c[0] +=1

       elif i>b:

        c[2] +=1

       else:

        c[1]+=1

print((min(c)))
n = int(eval(input()))
a, b = list(map(int, input().split()))
l = list(map(int, input().split()))
c = [0, 0, 0]
for i in l:
    if i <= a:
        c[0] += 1
    elif i > b:
        c[2] += 1
    else:
        c[1] += 1
print((min(c)))

n = int(eval(input()))
a, b = list(map(int, input().split()))
p = list(map(int, input().split()))
c = [0] * 3
for i in p:
    if i <= a:
        c[0] += 1
    elif i > b:
        c[2] += 1
    else:
        c[1] += 1
print((min(c)))

-l = list(map(int, input().split())) -c = [0, 0, 0] -for i in l: +p = list(map(int, input().split())) +c = [0] * 3 +for i in p: