Problem:
 Score : 200 points    Problem Statement You have written N problems to hold programming contests.
The i -th problem will have a score of P_i points if used in a contest.  With these problems, you would like to hold as many contests as possible under the following condition:   A contest has three problems. The first problem has a score not greater than A points, the second has a score between A + 1 and B points (inclusive), and the third has a score not less than B + 1 points.   The same problem should not be used in multiple contests.
At most how many contests can be held?      Constraints  3 \leq N \leq 100  1 \leq P_i \leq 20 ( 1 \leq i \leq N )  1 \leq A < B < 20  All values in input are integers.         Input Input is given from Standard Input in the following format:  N  A  B  P_1  P_2  ...  P_N       Output Print the answer.        Sample Input 1 7
5 15
1 10 16 2 7 20 12      Sample Output 1 2  Two contests can be held by putting the first, second, third problems and the fourth, fifth, sixth problems together.       Sample Input 2 8
3 8
5 5 5 10 10 10 15 20      Sample Output 2 0  No contest can be held, because there is no problem with a score of A = 3 or less.       Sample Input 3 3
5 6
5 6 10      Sample Output 3 1

Solution (Python):
import sys
sys.setrecursionlimit(10**7) 
import math
from copy import copy, deepcopy
from copy import deepcopy as dcp
from operator import itemgetter
from bisect import bisect_left, bisect, bisect_right

from collections import deque, defaultdict


from collections import Counter

from itertools import accumulate,combinations,permutations,product

from heapq import heapify,heappop,heappush


from functools import reduce,lru_cache

from decimal import Decimal

def input(): 
    x=sys.stdin.readline()
    return x[:-1] if x[-1]=="\n" else x
def printe(*x):print("
def printl(li): _=print(*li, sep="\n") if li else None
def argsort(s, return_sorted=False): 
    inds=sorted(range(len(s)), key=lambda k: s[k])
    if return_sorted: return inds, [s[i] for i in inds]
    return inds
def alp2num(c,cap=False): return ord(c)-97 if not cap else ord(c)-65
def num2alp(i,cap=False): return chr(i+97) if not cap else chr(i+65)
def matmat(A,B):
    K,N,M=len(B),len(A),len(B[0])
    return [[sum([(A[i][k]*B[k][j]) for k in range(K)]) for j in range(M)] for i in range(N)]
def matvec(M,v):
    N,size=len(v),len(M)
    return [sum([M[i][j]*v[j] for j in range(N)]) for i in range(size)]
def T(M):
    n,m=len(M),len(M[0])
    return [[M[j][i] for j in range(n)] for i in range(m)]
def main():
    mod = 1000000007
    

    N = int(input())
    A,B= map(int, input().split())
    P = tuple(map(int, input().split())) 
    
    
    c0=c1=c2=0
    for p in P:
        if p<=A:
            c0+=1
        elif p<=B:
            c1+=1
        else:
            c2+=1
    print(min(c1,c2,c0))




if __name__ == "__main__":
    main()

Solution (Python):
N = int(input())
A, B = map(int, input().split())

c = [0] * 3
for P in map(int, input().split()):
    if P <= A:
        c[0] += 1
    elif A < P <= B:
        c[1] += 1
    else:
        c[2] += 1

print(min(c))

Solution (Python):
def main():
    n=int(input())
    a,b=map(int,input().split())
    p=map(int,input().split())
    A,B,C = 0,0,0
    for pp in p:
        if pp <= a:
            A += 1
        elif pp <= b:
            B += 1
        else:
            C += 1
    print(min(A,B,C))

if __name__ == "__main__":
    main()

Solution (Python):
def main():
    n=int(input())
    a,b=map(int, input().split())
    p = map(int,input().split())
    A,B,C = 0, 0, 0
    for pp in p:
        if pp <= a:
            A += 1
        elif pp <= b:
            B += 1
        else:
            C += 1
    print(min(A,B,C))
    
if __name__ == "__main__":
    main()

Solution (Python):
N = int(input())
A,B = map(int,input().split())
P = list(map(int,input().split()))

q1 = []
q2 = []
q3 = []
for i in range(N):
  if P[i] <= A:
    q1.append(P[i])
  elif P[i] <= B:
    q2.append(P[i])
  else:
    q3.append(P[i])
print(min(len(q1),len(q2),len(q3)))

Solution (Python):
N = int(input())
A, B = map(int, input().split())
P = list(map(int, input().split()))

first_cnt = 0
second_cnt = 0
third_cnt = 0

for i in range(N):
    if P[i] <= A:
        first_cnt += 1
    elif P[i] <= B:
        second_cnt += 1
    else:
        third_cnt += 1

print(min(first_cnt, second_cnt, third_cnt))

Solution (Python):
N,A,B,*P=map(int,open(0).read().split())
C=[0]*3
for p in P:
    C[(A<p)+(B<p)]+=1
print(min(C))

Solution (Python):
N=int(input())
A,B=map(int,input().split())
*P,=map(int,input().split())

X=Y=Z=0
for p in P:
    if p<=A:
        X+=1
    elif B<p:
        Z+=1
    else:
        Y+=1

print(min([X,Y,Z]))

Solution (Python):
import sys

sys.setrecursionlimit(10 ** 6)
int1 = lambda x: int(x) - 1
p2D = lambda x: print(*x, sep="\n")
def II(): return int(sys.stdin.readline())
def MI(): return map(int, sys.stdin.readline().split())
def LI(): return list(map(int, sys.stdin.readline().split()))
def LLI(rows_number): return [LI() for _ in range(rows_number)]
def SI(): return sys.stdin.readline()[:-1]

def main():
    n=II()
    a,b=MI()
    pp=MI()
    cnt=[0]*3
    for p in pp:
        if p>b:cnt[0]+=1
        elif p>a:cnt[1]+=1
        else:cnt[2]+=1
    print(min(cnt))

main()

Solution (Python):
n = int(input())
a,b = map(int,input().split())
p = list(map(int,input().split()))

res = [0]*3

for v in p:
    if v <= a:
        res[0]+=1
    elif a < v <= b:
        res[1]+=1
    else:
        res[2]+=1
print(min(res))

Solution (Python):
def main():
    n = int(input())
    a, b = list(map(int, input().split()))
    P = list(map(int, input().split()))
    ans = [[] for _ in range(3)]
    for p in P:
        if p <= a:
            ans[0].append(p)
        elif a + 1 <= p <= b:
            ans[1].append(p)
        else:
            ans[2].append(p)
    print(min(list(map(len, ans))))

if __name__ == '__main__':
    main()

Solution (Python):
n = int(input())
a,b = map(int,input().split())
L = list(map(int,input().split()))

p,q,r = [],[],[]
for i in range(n):
    if 0<=L[i]<=a:
        p.append(L[i])
    elif a+1 <= L[i] <=b:
        q.append(L[i])
    else:
        r.append(L[i])
print(min(len(p),len(q),len(r)))

Solution (Python):
import sys
input = sys.stdin.readline

def I(): return int(input())
def MI(): return map(int, input().split())
def LI(): return list(map(int, input().split()))

def main():
    mod=10**9+7
    N=I()
    A,B=MI()
    P=LI()
    P.sort()
    L=[0,0,0]
    for i in range(N):
        if P[i]<=A:
            L[0]+=1
        elif A+1<=P[i]<=B:
            L[1]+=1
        else:
            L[2]+=1
            
    print(min(L))
            
    

main()

Solution (Python):
n = int(input())
a, b = map(int, input().split())
P = list(map(int, input().split()))

x = 0
y = 0
z = 0
for p in P:
    if p <= a:
        x += 1
    elif a+1 <= p <= b:
        y += 1
    else:
        z += 1
print(min([x, y, z]))

Solution (Python):
n = int(input())
a, b = map(int, input().split())
P = list(map(int, input().split()))

x = 0
y = 0
z = 0
for p in P:
    if p <= a:
        x += 1
    elif a+1 <= p <= b:
        y += 1
    else:
        z += 1
print(min([x, y, z]))

Solution (Python):
n=int(input())
a,b=map(int,input().split())
x,y,z=0,0,0
lst=list(map(int,input().split()))
for i in lst:
  if i<=a:
    x+=1
  elif a<i<=b:
    y+=1
  else:
    z+=1
o=[x,y,z]
print(min(o))

Solution (Python):
N = int(input())
A,B = map(int,input().split())
P = list(map(int,input().split()))
x = 0
y = 0
z = 0
for i in range(N):
  if(P[i]<=A):
    x+=1
  elif P[i]<=B:
    y+=1
  else:
    z+=1
print(min(x,y,z))

Solution (Python):
n = int(input())
a, b = map(int, input().split())
lst = list(map(int, input().split()))
diff = [0] * 3
for i in range(n):
  if lst[i] <= a:
    diff[0] += 1
  elif lst[i] <= b:
    diff[1] += 1
  else:
    diff[2] += 1
print(min(diff))

Solution (Python):
import sys, re
from collections import deque, defaultdict, Counter
from math import ceil, sqrt, hypot, factorial, pi, sin, cos, radians
from itertools import accumulate, permutations, combinations, product
from operator import itemgetter, mul
from copy import deepcopy
from string import ascii_lowercase, ascii_uppercase, digits
from bisect import bisect, bisect_left
from fractions import gcd
from heapq import heappush, heappop
from functools import reduce
def input(): return sys.stdin.readline().strip()
def INT(): return int(input())
def MAP(): return map(int, input().split())
def LIST(): return list(map(int, input().split()))
def ZIP(n): return zip(*(MAP() for _ in range(n)))
sys.setrecursionlimit(10 ** 9)
INF = float('inf')
mod = 10 ** 9 + 7

N = INT()
A, B = MAP()
P = LIST()
L = [-1, A, B, 20]
print(min(map(len, [[x for x in P if L[i] < x <= L[i+1]] for i in range(3)])))

Solution (Python):
n = int(input())
a,b = map(int, input().split())
p = list(map(int, input().split()))

cnt=[0,0,0]
for poi in p:
  if poi <= a:
  	cnt[0]+=1
  elif poi <=b:
    cnt[1]+=1
  else:
    cnt[2]+=1
print(min(cnt))

Solution (Python):
n, a, b, *P = map(int, open(0).read().split())
cnt = [0]*3
for p in P:
    if p <= a:
        cnt[0] += 1
    elif a < p <= b:
        cnt[1] += 1
    else:
        cnt[2] += 1
print(min(cnt))

Solution (Python):
n=int(input())
a,b=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))

Solution (Python):
n = int(input())
a,b = 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))

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

Solution (Python):
n = int(input())
a, b = map(int, input().split())
p = list(map(int, input().split()))
ans = 0
c = 0
d = 0
e = 0
for i in range(n):
  if p[i] <= a:
    c += 1
  elif a + 1 <= p[i] <= b:
    d += 1
  elif p[i] >= b + 1:
    e += 1
ans = min(c, d, e)
print(ans)

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

Solution (Python):
from sys import stdin
N = int(stdin.readline().rstrip())
A, B = [int(_) for _ in stdin.readline().rstrip().split()]
P = [int(_) for _ in stdin.readline().rstrip().split()]
a, ab, b = 0, 0, 0
for p in P:
    if p <= A:
        a += 1
    elif A < p <= B:
        ab += 1
    elif B < p:
        b += 1
print(min(a, ab, b))

Solution (Python):
N = int(input())
A, B = map(int, input().split())
P = list(map(int, input().split()))
lst = [0, 0, 0]
for p in P:
    if p <= A:
        lst[0] += 1
    elif p <= B:
        lst[1] += 1
    else:
        lst[2] += 1

print (min(lst))

Solution (Python):
def resolve():
    N = int(input())
    A, B = map(int, input().split())
    P = list(map(int, input().split()))
    ans = [0, 0, 0]
    for i in range(N):
        if P[i] <= A:
            ans[0] += 1
        elif P[i] >= B+1:
            ans[2] += 1
        else:
            ans[1] += 1
    print(min(ans))
resolve()

Solution (Python):
import sys, re
from collections import deque, defaultdict, Counter
from math import ceil, sqrt, hypot, factorial, pi, sin, cos, tan, asin, acos, atan, radians, degrees
from itertools import accumulate, permutations, combinations, combinations_with_replacement, product, groupby
from operator import itemgetter, mul
from copy import deepcopy
from string import ascii_lowercase, ascii_uppercase, digits
from bisect import bisect, bisect_left, insort, insort_left
from fractions import gcd
from heapq import heappush, heappop
from functools import reduce
def input(): return sys.stdin.readline().strip()
def INT(): return int(input())
def MAP(): return map(int, input().split())
def LIST(): return list(map(int, input().split()))
def ZIP(n): return zip(*(MAP() for _ in range(n)))
sys.setrecursionlimit(10 ** 9)
INF = float('inf')
mod = 10**9 + 7


N = INT()
A, B = MAP()
P = LIST()

a = [0]*3

for x in P:
	if x <= A:
		a[0] += 1
	elif B < x:
		a[2] += 1
	else:
		a[1] += 1

print(min(a))

Solution (Python):
n=int(input())
a,b=map(int,input().split())
l=list(map(int,input().split()))

c0=0
c1=0
c2=0
for i in range(n):
    if l[i]<=a:
        c0+=1
    if a<l[i]<=b:
        c1+=1
    if l[i]>b:
        c2+=1
print(min(c0,c1,c2))

Solution (Python):
n = int(input())
a, b = map(int, input().split())
p = sorted(list(map(int, input().split())))

num1 = len([x for x in p if x <= a])
num2 = len([x for x in p if a < x <= b])
num3 = len([x for x in p if b < x])

print(min(num1, num2, num3))

Solution (Python):
N = int(input())
A, B = map(int, input().split())
P = list(map(int, input().split()))

low, middle, high = 0, 0, 0
for i in range(N):
    if P[i] <= A:
        low += 1
    elif P[i] <= B:
        middle += 1
    else:
        high += 1
print(min(low, middle, high))

Solution (Python):






import sys
input = sys.stdin.readline

import math

import bisect
from collections import defaultdict
from collections import deque
from collections import Counter
from functools import lru_cache






MOD = 10**9+7
INF = float('inf')






def I(): return int(input().strip())
def S(): return input().strip()
def IL(): return list(map(int,input().split()))
def SL(): return list(map(str,input().split()))
def ILs(n): return list(int(input()) for _ in range(n))
def SLs(n): return list(input().strip() for _ in range(n))
def ILL(n): return [list(map(int, input().split())) for _ in range(n)]
def SLL(n): return [list(map(str, input().split())) for _ in range(n)]


def P(arg): print(arg); return
def Y(): print("Yes"); return
def N(): print("No"); return
def E(): exit()
def PE(arg): print(arg); exit()
def YE(): print("Yes"); exit()
def NE(): print("No"); exit()


def DD(arg): return defaultdict(arg)



def inv(n): return pow(n, MOD-2, MOD)


kaijo_memo = []
def kaijo(n):
  if(len(kaijo_memo) > n):
    return kaijo_memo[n]
  if(len(kaijo_memo) == 0):
    kaijo_memo.append(1)
  while(len(kaijo_memo) <= n):
    kaijo_memo.append(kaijo_memo[-1] * len(kaijo_memo) % MOD)
  return kaijo_memo[n]

gyaku_kaijo_memo = []
def gyaku_kaijo(n):
  if(len(gyaku_kaijo_memo) > n):
    return gyaku_kaijo_memo[n]
  if(len(gyaku_kaijo_memo) == 0):
    gyaku_kaijo_memo.append(1)
  while(len(gyaku_kaijo_memo) <= n):
    gyaku_kaijo_memo.append(gyaku_kaijo_memo[-1] * pow(len(gyaku_kaijo_memo),MOD-2,MOD) % MOD)
  return gyaku_kaijo_memo[n]

def nCr(n,r):
  if(n == r):
    return 1
  if(n < r or r < 0):
    return 0
  ret = 1
  ret = ret * kaijo(n) % MOD
  ret = ret * gyaku_kaijo(r) % MOD
  ret = ret * gyaku_kaijo(n-r) % MOD
  return ret


def factorization(n):
  arr = []
  temp = n
  for i in range(2, int(-(-n**0.5//1))+1):
    if temp%i==0:
      cnt=0
      while temp%i==0: 
        cnt+=1 
        temp //= i
      arr.append([i, cnt])
  if temp!=1:
    arr.append([temp, 1])
  if arr==[]:
    arr.append([n, 1])
  return arr


def make_divisors(n):
  divisors = []
  for i in range(1, int(n**0.5)+1):
    if n % i == 0:
      divisors.append(i)
      if i != n // i: 
        divisors.append(n//i)
  return divisors


def make_primes(N):
  max = int(math.sqrt(N))
  seachList = [i for i in range(2,N+1)]
  primeNum = []
  while seachList[0] <= max:
    primeNum.append(seachList[0])
    tmp = seachList[0]
    seachList = [i for i in seachList if i % tmp != 0]
  primeNum.extend(seachList)
  return primeNum


def gcd(a, b):
    while b:
        a, b = b, a % b
    return a


def lcm(a, b):
    return a * b // gcd (a, b)


def count_bit(n):
  count = 0
  while n:
    n &= n -1
    count += 1
  return count


def base_10_to_n(X, n):
  if X//n:
    return base_10_to_n(X//n, n)+[X%n]
  return [X%n]

def base_n_to_10(X, n):
  return sum(int(str(X)[-i-1])*n**i for i in range(len(str(X))))


def int_log(n, a):
  count = 0
  while n>=a:
    n //= a
    count += 1
  return count




dic = DD(int)
N = I()
A,B = IL()
P = IL()

for p in P:
  if p<=A:
    dic[0] += 1
  elif p>B:
    dic[2] += 1
  else:
    dic[1] += 1
print(min(dic[0],dic[1],dic[2]))

Solution (Python):
n = int(input())
a, b = map(int,input().split())
li = list(map(int,input().split()))
x = 0
y = 0
z = 0

for i in li:
    if i <= a:
        x += 1
    elif i <= b:
        y += 1
    else:
        z += 1

print(min(x,y,z))

Solution (Python):
n=int(input())
a,b=map(int,input().split())
p=list(map(int,input().split()))
num1=0
num2=0
num3=0
for i in range(n):
    if p[i]<=a:
        num1+=1
    elif p[i]<=b:
        num2+=1
    else:
        num3+=1
print(min(num1,num2,num3))

Solution (Python):
from collections import deque
N=int(input())
a,b=map(int,input().split())
p=list(map(int,input().split()))
p.sort()
ans=0
x=0
y=0
z=0
for i in range(N):
    if p[i]<=a:
        x+=1
    if a+1<=p[i]<=b:
        y+=1
    if p[i]>=b+1:
        z+=1
print(min(x,y,z))

Solution (Python):
n = int(input())
a, b = map(int, input().split())
p = list(map(int, input().split()))
A, B, C = [], [], []
for i in p:
    if i <= a:
        A.append(i)
    elif i <= b:
        B.append(i)
    else:
        C.append(i)
print(min(len(A), len(B), len(C)))

Solution (Python):
n=int(input())
a,b=map(int,input().split())
p=sorted(list(map(int,input().split())))
x,y=-1,-1
for i in range(n):
    if x==-1 and p[i]>a:
        x=i
    if y==-1 and p[i]>b:
        y=i
if x==-1 or y==-1:
    print(0)
    exit()
print(min(x,y-x,n-y))

Solution (Python):
from statistics import median


from fractions import gcd
from itertools import combinations 
from collections import deque
from collections import defaultdict
import bisect










import sys
sys.setrecursionlimit(10000000)
mod = 10**9 + 7

def readInts():
  return list(map(int,input().split()))
def I():
  return int(input())
n = I()
A,B = readInts()
P = sorted(readInts())
i = 0
nya = 0
ans = 0
while i < n:
    if nya == 0:
        if 1 <= P[i] <= A:
            nya = 1
            P[i] = -1
    elif nya == 1:
        if A < P[i] <= B:
            nya = 2
            P[i] = -1
    elif nya == 2:
        if B < P[i]:
            nya = 0
            P[i] = -1
            ans += 1
            i = 0
    i += 1

print(ans)

Solution (Python):
N=int(input())
A,B=map(int,input().split())
P=list(map(int,input().split()))
  
s=0
t=0
u=0
  
for q in P:
  if q<=A:
    s += 1
  elif A+1<=q<=B:
    t += 1
  else:
    u += 1
print(min(s,t,u))

Solution (Python):
import sys

sys.setrecursionlimit(10 ** 7)
input = sys.stdin.readline
f_inf = float('inf')
mod = 10 ** 9 + 7


def resolve():
    N = int(input())
    A, B = map(int, input().split())
    P = list(map(int, input().split()))

    problem1, problem2, problem3 = [], [], []
    for p in P:
        if p <= A:
            problem1.append(p)
        elif A + 1 <= p <= B:
            problem2.append(p)
        else:
            problem3.append(p)

    res = min(len(problem1), len(problem2), len(problem3))
    print(res)


if __name__ == '__main__':
    resolve()

Solution (Python):
import bisect
n = int(input())
a,b = map(int,input().split())
p = list(map(int,input().split()))
p.sort()
a_ = bisect.bisect_right(p,a)
b_ = bisect.bisect_right(p,b)
print(min(a_,b_-a_,n-b_))

Solution (Python):
n = int(input())
a, b = map(int, input().split())
p = [int(_) for _ in input().split()]

num1, num2, num3 = 0, 0, 0
for i in p:
    if i <= a:
        num1 += 1
    elif b+1 <= i:
        num3 += 1
    else:
        num2 += 1
print(min(num1, num2, num3))

Solution (Python):
n = int(input())
a, b = map(int, input().split())
p = list(map(int, input().split()))
prob_1 = 0
prob_2 = 0
prob_3 = 0
for i in range(n):
  if p[i] <= a:
    prob_1 += 1
  elif p[i] <= b:
    prob_2 += 1
  else:
    prob_3 += 1
ans = min(prob_1, prob_2, prob_3)
print(ans)

Solution (Python):
n = int(input())
a,b = map(int,input().split())
p_list = list(map(int,input().split()))
p_list.sort()
ans = 0
dum1 = 0
dum2 = 0
dum3 = 0
for i in p_list:
    if i <= a:
        dum1 += 1
    if a+1 <= i <= b:
        dum2 += 1
    if i >= b+1:
        dum3 += 1
print(min(dum1,dum2,dum3))

Solution (Python):
def main():
    N  = int(input())
    A,B  = map(int, input().split()) 
    P = list(map(int, input().split()))  
    c1 = 0
    c2 = 0
    c3 = 0

    for i in range(len(P)):
        if P[i]<=A:
            c1 +=1
        elif P[i]<=B:
            c2 +=1
        else:
            c3 +=1
    print(min([c1,c2,c3]))




if __name__ == '__main__':
    main()

Solution (Python):
from sys import stdin
import math
import re
import queue

input = stdin.readline

MOD = 1000000007
INF = 122337203685477580

def solve():
    N = int(input().rstrip())
    A,B = map(int, input().split())
    X =list(map(int, input().split())) 
    vec = [0]*3
    for x in X:
        if(x <= A):
            vec[0] += 1
        elif(x <= B):
            vec[1] += 1
        else:
            vec[2] += 1
    

    print(min(vec))
if __name__ == '__main__':
    solve()

Solution (Python):
import sys

input = sys.stdin.readline


def main():
    N = int(input())
    A, B = map(int, input().split())
    P = list(map(int, input().split()))

    C = [0] * 3
    for p in P:
        if p <= A:
            C[0] += 1
        elif p <= B:
            C[1] += 1
        else:
            C[2] += 1
    
    ans = min(C)
    print(ans)


if __name__ == "__main__":
    main()

Solution (Python):
N = int(input())
A,B = list(map(int,input().split()))
P = list(map(int,input().split()))
AA = 0
AB = 0
BB = 0
for i in range(N):
    if P[i] <= A:
        AA += 1
    elif A+1 <= P[i] <= B:
        AB += 1
    else:
        BB += 1
print(min(AA,AB,BB))

Solution (Python):
import sys
sys.setrecursionlimit(10 ** 5 + 10)


def input(): return sys.stdin.readline().strip()


def resolve():

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


resolve()

Solution (Python):
import sys
def input(): return sys.stdin.readline().strip()

def resolve():
    n=int(input())
    a,b=map(int, input().split())
    l=list(map(int,input().split()))
    cnt1=0
    cnt2=0
    cnt3=0

    for i in l:
        if i<=a:
            cnt1+=1
        elif a+1<=i<=b:
            cnt2+=1
        else:
            cnt3+=1
    print(min(cnt1,cnt2,cnt3))


resolve()

Solution (Python):
n = int(input())
a,b = map(int, input().split())
p = list(map(int, input().split()))
A,B,C = 0,0,0
for v in p:
  if v <= a: A += 1
  elif v <= b: B += 1
  else: C += 1
print(min(A,B,C))

Solution (Python):
N=int(input())
A,B=map(int,input().split())
P=list(map(int,input().split()))
l=[0,0,0]
for i in P:
    if i<=A:
        l[0]+=1
    elif i<=B:
        l[1]+=1
    else:
        l[2]+=1
print(min(l))

Solution (Python):
n = int(input())
a, b = map(int, input().split())
lis_p = list(map(int, input().split()))
con1 = 0
con2 = 0
con3 = 0

for x in range(n):
  if lis_p[x] <= a:
    con1 += 1
  elif a+1 <= lis_p[x] <= b:
    con2 += 1
  else:
    con3 += 1

ans = 0
while True:
  if con1 == 0 or con2 == 0 or con3 == 0:
    break
  else:
    con1 -= 1
    con2 -= 1
    con3 -= 1
    ans += 1
print(ans)

Solution (Python):
n = int(input())
a,b = map(int,input().split())
P = list(map(int,input().split()))
q1 = 0
q2 = 0
q3 = 0
for p in P:
  if p <= a:
    q1 += 1
  elif a < p <= b:
    q2 += 1
  else:
    q3 += 1
print(min(q1,q2,q3))

Solution (Python):
n = int(input())
a, b = map(int, input().split())
p = list(map(int, input().split()))
x1 = 0
x2 = 0
x3 = 0
for i in p:
  if i <= a:
    x1 += 1
  elif i <= b:
    x2 += 1
  else:
    x3 += 1
print(min(x1, x2, x3))

Solution (Python):
n = int(input())
a,b = map(int,input().split())
p = list(map(int,input().split()))

s = [0,0,0]

for i in p:
    if(i <= a):s[0] += 1
    elif(i <= b):s[1] += 1
    else:s[2] += 1
print(min(s))

Solution (Python):
n=int(input())
A,B=map(int, input().split())
P=list(map(int, input().split()))
s=[]
w=[]
t=[]
l=[s,w,t]
for i in range(n):
  if P[i]<=A:
    s.append(P[i])
  elif P[i]>=A+1 and P[i]<=B:
    w.append(P[i])
  else:
    t.append(P[i])
print(min(len(s),len(w),len(t)))

Solution (Python):
n=int(input())
a,b=map(int,input().split())
p=sorted(list(map(int,input().split())))

l1=[]
l2=[]
l3=[]

for i in range(n):
    if p[i]<=a:
        l1.append(p[i])

for i in range(n):
    if a+1<=p[i]<=b:
        l2.append(p[i])
        
for i in range(n):
    if b<p[i]:
        l3.append(p[i])
        
print(min(len(l1),len(l2),len(l3)))

Solution (Python):
n=int(input())
a,b=[int(s) for s in input().split()]
P=[int(s) for s in input().split()]

lea=[p for p in P if p<=a]
gealeb=[p for p in P if a<p<=b]
gtb=[p for p in P if p>b]

print(min(len(lea),len(gealeb),len(gtb)))

Solution (Python):

N = int(input())
A, B = [int(s) for s in input().split()]
P = [int(s) for s in input().split()]

leA = [p for p in P if p <= A]
gtAleB = [p for p in P if A < p <= B]
gtB = [p for p in P if p > B]

print(min(len(leA), len(gtAleB), len(gtB)))

Solution (Python):

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

l1 = []
l2 = []
l3 = []

for i in range(n):
    if p[i] <= a:
        l1.append(p[i])
 
for i in range(n):
    if a+1 <= p[i] <= b:
        l2.append(p[i])
 
for i in range(n):
    if b < p[i]:
        l3.append(p[i])

print(min(len(l1),len(l2),len(l3)))

Solution (Python):
n = int(input())
a,b = map(int, input().split())
res = [0,0,0]
arr = list(map(int, input().split()))
for i in range(n):
  if arr[i] <= a:
    res[0] += 1
  elif arr[i] <= b:
    res[1] += 1
  else:
    res[2] += 1
print(min(res))

Solution (Python):
import sys
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines
sys.setrecursionlimit(10 ** 7)

n = int(readline())
a, b = map(int, readline().split())
p = list(map(int, readline().split()))
memo = [0, 0, 0]
for check in p:
    if check <= a:
        memo[0] += 1
    elif a < check <= b:
        memo[1] += 1
    else:
        memo[2] += 1
print(min(memo))

Solution (Python):
N=int(input())
A,B=map(int,input().split())
P=input().split()
P_low=[int(x) for x in P if int(x)<=A]
P_normal=[int(x) for x in P if A+1<=int(x)<=B]
P_high=[int(x) for x in P if B+1<=int(x)]


ans=P_low
if len(ans)<=len(P_normal):
    pass
else:
    ans=P_normal
if len(ans)<=len(P_high):
    pass
else:
    ans=P_high
print(len(ans))

Solution (Python):
N = int(input())
A, B = map(int, input().split())
P = list(map(int, input().split()))

s1, s2, s3 = 0, 0, 0
for p in P:
    if p <= A:
        s1 += 1
    elif A+1 <= p <= B:
        s2 += 1
    else:
        s3 += 1
print(min(s1, s2, s3))

Solution (Python):
import sys
stdin = sys.stdin
sys.setrecursionlimit(10**6)
ni = lambda: int(ns())
na = lambda: list(map(int, stdin.readline().split()))
nn = lambda: list(stdin.readline().split())
ns = lambda: stdin.readline().rstrip()

n = ni()
a,b = na()
p = na()
c = [0,0,0]

for i in p:
    if i <= a:
        c[0] += 1
    elif a+1 <= i <= b:
        c[1] += 1
    else:
        c[2] += 1

print(min(c))

Solution (Python):
n = int(input())
a,b = map(int,input().split())
P = list(map(int,input().split()))
ask = [0,0,0]
for p in P:
    if p <= a:
        ask[0] += 1
    elif a+1 <= p <= b:
        ask[1] += 1
    else:
        ask[2] += 1
print(min(ask))

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

Solution (Python):
n = int(input())
a,b = map(int,input().split())
p = list(map(int,input().split()))
cnt1 = 0
cnt2 = 0
cnt3 =0

for i in range(n):
    if p[i] <= a:
        cnt1 +=1
    elif a < p[i] <= b:
        cnt2+=1
    else:
        cnt3+=1
ans = min(cnt1,cnt2,cnt3)
print(ans)

Solution (Python):


if False:
    print('YES' if set(input().split())==set(list('1974')) else 'NO')



if False:
    S=input()
    ans='NO'
    K='keyence'
    for i in range(len(K)):
        l=K[:i]
        r=K[i:]
        
        if l in S and r in S:
            l_i=S.index(l)
            for j in range(len(S)):
                
                if j+len(r)-1<len(S) and S[j:j+len(r)]==r:
                    r_i=j
            
            if l_i<=r_i:
                ans='YES'
                break
    print(ans)



if False:
    N=int(input())
    H=int(input())
    W=int(input())
    print((N-H+1)*(N-W+1))



N=int(input())
A,B=map(int,input().split())
P=[int(i) for i in input().split()]
cnt=[0,0,0]
for p in P:
    if p<=A: cnt[0]+=1
    elif A<p<=B: cnt[1]+=1
    else: cnt[2]+=1
print(min(cnt))

Solution (Python):
import sys
f = sys.stdin
n = int(f.readline())
a, b = map(int,f.readline().split())
P = list(map(int, f.readline().split()))
x = [0 for _ in range(3)]
for p in P:
  if p <= a:
    x[0]+=1
  elif p <= b:
    x[1] += 1
  else:
    x[2] += 1
print(min(x))

Solution (Python):
n = int(input())
a, b = map(int, input().split())
p = list(map(int, input().split()))
x, y, z = 0, 0, 0
for i in p:
    if i <= a:
        x += 1
    elif i <= b:
        y += 1
    else:
        z += 1
print(min(x, y, z))

Solution (Python):
def main():
    import sys
    input = sys.stdin.readline
    sys.setrecursionlimit(10**7)
    from collections import Counter, deque
    
    from itertools import combinations, permutations, accumulate, groupby, product
    from bisect import bisect_left,bisect_right
    from heapq import heapify, heappop, heappush
    from math import floor, ceil
    

    
    

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

if __name__ == '__main__':
    main()

Solution (Python):
n=int(input())
a,b=map(int,input().split())
p=list(map(int,input().split()))
one=0
two=0
three=0
for i in range(n):
    if p[i]<=a:
        one+=1
    elif b+1>p[i]>a:
        two+=1
    else:
        three+=1
print(min(one,two,three))

Solution (Python):
n=int(input())
a,b=map(int,input().split())
H=list(map(int,input().split()))
d=[]
e=[]
f=[]
for i in range(n):
    k=H[i]
    if k<=a:
        d.append(k)
    elif a<k<=b:
        e.append(k)
    else:
        f.append(k)
print(min(len(d),len(e),len(f)))

Solution (Python):
_,a,b,*p=map(int,open(0).read().split())
print(min(eval("sum(%s for j in p)"%["j<=a","a<j<=b","b<j"][i]) for i in range(3)))

Solution (Python):
n, a, b, *p = map(int, open(0).read().split())
print(min(eval("sum(%s for j in p)" % ["j<=a", "a<j<=b", "b<j"][i]) for i in range(3)))

Solution (Python):
N = int(input())
A, B = list(map(int, input().split()))
P = list(map(int, input().split()))

a = sum(p <= A for p in P)
b = sum(A < p <= B for p in P)
c = sum(B < p for p in P)

print(min(a, b, c))

Solution (Python):
import sys
from sys import stdin

n = int(stdin.readline().rstrip())
a, b = map(int, stdin.readline().rstrip().split())
p = list(map(int, stdin.readline().rstrip().split()))
ans1 = 0
ans2 = 0
ans3 = 0
p.sort()

for pi in p:
    if pi <= a:
        ans1 += 1
    elif pi > a and pi <= b:
        ans2 += 1
    else:
        ans3 += 1

print(min(ans1, ans2, ans3))