Harryxun/sft_time huggingface dataset:
### BUGGY CODE ###

#!usr/bin/env python3
from collections import defaultdict, deque
from heapq import heappush, heappop
from itertools import permutations
import sys
import math
import bisect


def LI(): return [int(x) for x in sys.stdin.readline().split()]


def I(): return int(sys.stdin.readline())


def LS(): return [list(x) for x in sys.stdin.readline().split()]


def S():
    res = list(sys.stdin.readline())
    if res[-1] == "\n":
        return res[:-1]
    return res


def IR(n):
    return [I() for i in range(n)]


def LIR(n):
    return [LI() for i in range(n)]


def SR(n):
    return [S() for i in range(n)]


def LSR(n):
    return [LS() for i in range(n)]


sys.setrecursionlimit(1000000)
mod = 1000000007


def solve():
    n = I()
    sli = [input() for i in range(n)]
    rank = defaultdict(lambda: 0)
    for i in sli:
        rank[i] += 1
    for i in sorted([k for k, v in rank.items() if v == max(rank.values())]):
        print(i)


# Solve
if __name__ == "__main__":
    solve()


### FIXED CODE ###

#!usr/bin/env python3
from collections import defaultdict, deque
from heapq import heappush, heappop
from itertools import permutations
import sys
import math
import bisect


def LI(): return [int(x) for x in sys.stdin.readline().split()]


def I(): return int(sys.stdin.readline())


def LS(): return [list(x) for x in sys.stdin.readline().split()]


def S():
    res = list(sys.stdin.readline())
    if res[-1] == "\n":
        return res[:-1]
    return res


def IR(n):
    return [I() for i in range(n)]


def LIR(n):
    return [LI() for i in range(n)]


def SR(n):
    return [S() for i in range(n)]


def LSR(n):
    return [LS() for i in range(n)]


sys.setrecursionlimit(1000000)
mod = 1000000007


def solve():
    n = I()
    sli = [input() for i in range(n)]
    rank = defaultdict(lambda: 0)
    for i in sli:
        rank[i] += 1
    rank = list(rank.items())
    rank.sort(key=lambda x: (-x[1], x[0]))
    for i, j in rank:
        if j == rank[0][1]:
            print(i)


# Solve
if __name__ == "__main__":
    solve()
### BUGGY CODE ###

from collections import deque
H,W=map(int,input().split())
S=[list(input()) for _ in range(H)]
A=[[0]*W for _ in range(H)]
ans=[]

for i in range(H):
    for j in range(W):
        sy=i
        sx=j
        if S[i][j]=='#':
            continue
        A[i][j]=1
        for k in range(H):
            for l in range(W):
                ey=k
                ex=l
                if S[k][l]=='#':
                    continue
                if A[ey][ex]==1:
                    continue
                route=deque([(sy,sx,0)])
                while route:
                    a,b,n=route.popleft()
                    if a==ey and b==ex:
                        ans.append(n)
                        break
                    if 0<=a<=H-1 and 0<=b<=W-1:
                        if S[a][b]=='.':
                            S[a][b]=='#'
                            route.append((a+1,b,n+1))
                            route.append((a-1,b,n+1))
                            route.append((a,b+1,n+1))
                            route.append((a,b-1,n+1))

print(max(ans))      

### FIXED CODE ###

from collections import deque
import copy
H,W=map(int,input().split())
S=[list(input()) for _ in range(H)]
S1=copy.deepcopy(S)
ans=[]

sy=0
sx=0
for i in range(H):
    for j in range(W):
        c=0
        route=deque([(i,j,0)])
        S=copy.deepcopy(S1)
        while route:
            a,b,n=route.popleft()
            c=n
            if 0<=a<=H-1 and 0<=b<=W-1:
                if S[a][b]=='.':
                    S[a][b]='#'
                    route.append((a+1,b,n+1))
                    route.append((a-1,b,n+1))
                    route.append((a,b+1,n+1))
                    route.append((a,b-1,n+1))
                    
        ans.append(c-1)

print(max(ans))
### BUGGY CODE ###

n = int(input())
c = input()

wi = c.find('W')
ri = c.rfind('R')

if wi == -1 or ri == -1:
    print(0)
else:
    ans = 0
    while wi < ri:
        s = list(c)
        s[wi] = 'R'
        s[ri] = 'W'
        c = ''.join(s)
        wi = c.find('W')
        ri = c.rfind('R')
        ans += 1

    print(ans)

### FIXED CODE ###

n = int(input())
c = input()

wi = c.find('W')
ri = c.rfind('R')

if wi == -1 or ri == -1:
    print(0)
else:
    ans = 0
    while wi < ri:
        wi += 1
        wi = c[wi:].find('W') + wi
        ri = c[:ri].rfind('R')
        ans += 1

    print(ans)
### BUGGY CODE ###

N = int(input())
A = list(map(int, input().split()))
A.sort()

B = [0]*(max(A)+1)

for i in A:
  B[i]+=1
  if B[i] == 1:
    for j in range(i*2, max(A)+1, i):
      B[j]+=100
print(B.count(1))

### FIXED CODE ###

N = int(input())
A = list(map(int, input().split()))
A.sort()

m_a = max(A)+1
B = [0]*(m_a)

for i in A:
  B[i]+=1
  if B[i] == 1:
    for j in range(i*2, m_a, i):
      B[j]+=100
print(B.count(1))
### BUGGY CODE ###

N = int(input())
A = [int(input()) for n in range(N)]

setA = set(A)

if len(setA) < 100:
    res = 0
    for a in setA:
        if A.count(a)%2 != 0:
            res += 1
    
    print(res)

else:
    res = []
    while A:
        a = A.pop()
        if a in res:
            res.remove(a)
        else:
            res.append(a)
    
    print(len(res))

### FIXED CODE ###

N = int(input())
A = [int(input()) for n in range(N)]
A = sorted(A)

res = []
tmp = A[0]
count = 1
for i in range(1,N):
    if A[i] == tmp:
        count += 1
    else:
        res.append(count%2 != 0)
        count = 1
    tmp = A[i]
res.append(count%2 != 0)

print(sum(res))
### BUGGY CODE ###

def main():
  n = int(input())
  s = input()
  s1 = []
  s2 = []
  s3 = []
  ss = [("R",s.count("R")),("G",s.count("G")),("B",s.count("B"))]
  ss = sorted(ss,key=lambda x:x[1])
  ans = ss[0][1]*ss[1][1]*ss[2][1]
  for i in range(n):
    if s[i]==ss[0][0]:
      s1.append(i)
    if s[i]==ss[1][0]:
      s2.append(i)
    if s[i]==ss[2][0]:
      s3.append(i)
      
  for i in s1:
    for j in s2:
      if i*2-j in s3:
        ans -= 1
      if j*2-i in s3:
        ans -= 1
      if (i+j)/2 in s3:
        ans -= 1
  print(ans)
main()

### FIXED CODE ###

def main():
  n = int(input())
  s = input()
  ans = s.count("R")*s.count("G")*s.count("B")
  for i in range(n-2):
    for j in range(i+1,n-1):
      k = j + j - i
      if k >= n:
        break
      elif s[i] != s[j] and s[i] != s[k] and s[k] != s[j]:
        ans -=1
  print(ans)
main()
### BUGGY CODE ###

from collections import deque
from heapq import heapify,heappop,heappush,heappushpop
from copy import copy,deepcopy
from itertools import permutations,combinations
from collections import Counter
from pprint import pprint

def myinput():
    return map(int,input().split())

def mycol(data,col):
    return [ row[col] for row in data ]

def mysort(data,col):
    data.sort(key=lambda x:x[col],reverse=False)
    return data

def mymax(data):
    M = -1*float("inf")
    for i in range(len(data)):
        m = max(data[i])
        M = max(M,m)
    return M

def mymin(data):
    m = float("inf")
    for i in range(len(data)):
        M = min(data[i])
        m = min(m,M)
    return m

n = int(input())
s = input()

r = []
g = []
b = []
for i in range(n):
    if s[i]=="R":
        r.append(i)
    elif s[i]=="G":
        g.append(i)
    elif s[i]=="B":
        b.append(i)
    else:
        pass
# print(r,g,b)

def mycount(r,g,b):
    c = 0
    for i in r:
        ng = [ x for x in g if x>i ]
        for j in ng:
            nb = [ y for y in b if y>j ]
            for k in nb:
                if (j-i)!=(k-j):
                    c += 1
                else:
                    pass
    return c

ans = 0
ans += mycount(r,g,b)
ans += mycount(r,b,g)
ans += mycount(g,r,b)
ans += mycount(g,b,r)
ans += mycount(b,r,g)
ans += mycount(b,g,r)
print(ans)

### FIXED CODE ###

n = int(input())
s = input()

r = []
g = []
b = []
for i in range(n):
    if s[i]=="R":
        r.append(i)
    elif s[i]=="G":
        g.append(i)
    elif s[i]=="B":
        b.append(i)
    else:
        pass
# print(r,g,b)
count = 0
for i in range(n):
    x = s[i]
    for sa in range(n):
        j = i + sa
        k = j + sa
        if j<n:
            y = s[j]
        else:
            break
        if k<n:
            z = s[k]
        else:
            break
        if x!=y and y!=z and z!=x:
            count += 1
# print(count)
ans = len(r) * len(g) * len(b) - count
print(ans)
### BUGGY CODE ###

#from pprint import pprint
#from collections import defaultdict
#from collections import Counter
#from copy import deepcopy
#from itertools
#import sys 
#sys.setrecursionlimit(N) #N回まで再起を許可する。

# = map(int,input().split())

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

# = [list(map(int,input().split())) for _ in range(XXXX)]

from collections import deque






n,m = map(int,input().split())

ab_list = [list(map(int,input().split())) for _ in range(m)]

ab_count = {key:[] for key in range(1,n+1)}

for i in range(m):
    ab_count[ab_list[i][0]].append(ab_list[i][1])
    ab_count[ab_list[i][1]].append(ab_list[i][0])


#print(ab_count)

que = deque()

#始点は1、階層は0からスタート
que.append([1,0])

checked_dict = {key:[] for key in range(1,n+1)}
temp_dict = {key:[] for key in range(1,n+1)}
where = 0

while que:
    x_pop = que.popleft()
    x = x_pop[0]
    if where != x_pop[1]:
        #階層が代わったから、temp_dictをchecked_dictへ反映させる処理
        for k in range(1,n+1):
            if len(checked_dict[k]) == 0:
                checked_dict[k] = temp_dict[k]
            else:
                aaa = set(checked_dict[k]) & set(temp_dict[k])
                if aaa != set():
                    checked_dict[k] = list(aaa)

    
    where = x_pop[1]

    for j in ab_count[x]:
        if len(checked_dict[j]) == 0:
            #OK,temp_dictに入れて、queに入れる。
            temp_dict[j].append(x)
            que.append([j,where+1])
        else:
            continue

    

print("Yes")
for i in range(2,n+1):
    print(checked_dict[i][0])



### FIXED CODE ###

from collections import deque


n,m = map(int,input().split())

ab_list = [list(map(int,input().split())) for _ in range(m)]

ab_count = {key:[] for key in range(1,n+1)}

for i in range(m):
    ab_count[ab_list[i][0]].append(ab_list[i][1])
    ab_count[ab_list[i][1]].append(ab_list[i][0])


#print(ab_count)

que = deque()

#始点は1、階層は0からスタート
que.append([1,0])

checked_dict = {key:[] for key in range(1,n+1)}
#temp_dict = {key:[] for key in range(1,n+1)}
where = 0

while que:
    x_pop = que.popleft()
    x = x_pop[0]
    if where != x_pop[1]:
        pass
        ##階層が代わったから、temp_dictをchecked_dictへ反映させる処理
        #for k in range(1,n+1):
        #    if len(checked_dict[k]) == 0:
        #        checked_dict[k] = temp_dict[k]
        #    else:
        #        aaa = set(checked_dict[k]) & set(temp_dict[k])
        #        if aaa != set():
        #            checked_dict[k] = list(aaa)

    where = x_pop[1]

    for j in ab_count[x]:
        if len(checked_dict[j]) == 0:
            #OK,temp_dictに入れて、queに入れる。
            #temp_dict[j].append(x)
            checked_dict[j].append(x)
            que.append([j,where+1])
        else:
            continue

    

print("Yes")
for i in range(2,n+1):
    print(checked_dict[i][0])
### BUGGY CODE ###

import sys
input = sys.stdin.readline

n, k = map(int, input().split())
m = {}
ml = list()

for i in range(n):
    a, b = map(int, input().split())
    if a not in ml:
        ml.append(a)
        
    if m.get(a):
        m[a] += b
    else:
        m[a] = b

ml.sort()
for v in ml:
    if k > m[v]:
        k -= m[v]
    else:
        print(v)
        break

### FIXED CODE ###

import sys
input = sys.stdin.readline

n, k = map(int, input().split())
m = {}
ml = set()

for i in range(n):
    a, b = map(int, input().split())
    ml.add(a)
        
    if m.get(a):
        m[a] += b
    else:
        m[a] = b

mm = list(ml)
mm.sort()
for v in mm:
    if k > m[v]:
        k -= m[v]
    else:
        print(v)
        break
### BUGGY CODE ###

N, K = map(int, input().split())
h = [0] + list(map(int, input().split()))
dp = [0 for i in range(N+1)]

for i in range(2, N+1):
    kouho = []
    for k in range(1, min(i-1, K)+1):
        kouho.append(dp[i-k] + abs(h[i]-h[i-k]))
    dp[i] = min(kouho)
print(dp[N])

### FIXED CODE ###

N, K = map(int, input().split())
h = [0] + list(map(int, input().split()))
dp = [0 for i in range(N+1)]

for i in range(2, N+1):
    kouho = []
    for k in range(1, min(i-1, K)+1):
        kouho.append(dp[i-k] + abs(h[i]-h[i-k]))
    dp[i] = min(kouho)
print(dp[N])
### BUGGY CODE ###

N, K = [int(n) for n in input().split()]
#dice = [int(n) for n in input().split()]
evs = [(1 + int(n))/2 for n in input().split()]
maxev = 0
for i in range(N - K + 1):
    current_ev = 0
    for j in range(K):
        current_ev += evs[i + j]
    maxev = max(maxev, current_ev)

print(maxev)

### FIXED CODE ###

N, K = [int(n) for n in input().split()]
#dice = [int(n) for n in input().split()]
evs = [(1 + int(n))/2 for n in input().split()]
cumsum = [0]

for i in range(1,N+1):
    cumsum.append(cumsum[i-1] + evs[i-1])

k_cum = [cumsum[i+K] - cumsum[i] for i in range(N-K+1)]

print(max(k_cum))
### BUGGY CODE ###

# coding: utf-8


def solve(*args: str) -> str:
    t = int(args[0])
    ret = []
    for i in range(1, 3*t+1, 3):
        n = int(args[i])
        A = map(int, args[i+1].split())
        S = map(int, tuple(args[i+2]))

        A0 = []
        A1 = []
        for a, s in zip(A, S):
            if s == 1:
                A0.append(a)
            elif s == 0:
                A1.append(a)

        X = set([0])
        for a in A1:
            for x in X.copy():
                X.add(a ^ x)

        Y = set([0])
        for a in A0:
            for y in Y.copy():
                Y.add(a ^ y)

        ret.append(0 if X <= Y else 1)

    return '\n'.join(map(str, ret))


if __name__ == "__main__":
    print(solve(*(open(0).read().splitlines())))


### FIXED CODE ###

# coding: utf-8


def solve(*args: str) -> str:
    t = int(args[0])
    ret = []
    for i in range(1, 3*t+1, 3):
        n = int(args[i])
        A = tuple(map(int, args[i+1].split()))
        S = tuple(map(int, tuple(args[i+2])))

        ans = False
        dp = [0]*(max(A).bit_length()+1)
        for a, s in reversed(tuple(zip(A, S))):
            m = a.bit_length()
            if s == 0:
                while 0 < a and 0 < dp[m]:
                    a ^= dp[m]
                    m = a.bit_length()
                if 0 < a:
                    dp[m] = a
            elif s == 1:
                while 0 < a:
                    if 0 < dp[m]:
                        a ^= dp[m]
                        m = a.bit_length()
                    else:
                        ans = True
                        break

        ret.append(1*ans)

    return '\n'.join(map(str, ret))


if __name__ == "__main__":
    print(solve(*(open(0).read().splitlines())))
### BUGGY CODE ###

def resolve():
    n, k = map(int, input().split())
    p = list(map(int, input().split()))
    l = tuple(map(lambda x: x * (x + 1) * 1 / 2 * 1 / x, p))
    ans = [0] * (n - k + 1)
    for i in range(n - k + 1):
        ans[i] = sum(l[i:i + k])
    print(max(ans))

if __name__ == "__main__":
    resolve()

### FIXED CODE ###

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

p = list(map(lambda x: x * (x+1) /2 /x, p))

for i in range(1, n):
    p[i] = p[i-1] + p[i]

m = p[k-1]
for i in range(k, n):
    a = p[i] - p[i-k]
    if m < a:
        m = a

print(m)
### BUGGY CODE ###

import numpy as np
N,M=map(int,input().split()) #N個の商品、M枚の割引券
A=np.array(input().split(),dtype=int) #i番目に買う値段はA[i]円
for i in range(M):
    A[np.argmax(A)]//=2
print(sum(A))

### FIXED CODE ###

import heapq

N,M=map(int,input().split())
A=list(map(int,input().split()))

for i in range(N):
    A[i]*=-1
#print(A)
heapq.heapify(A)
for i in range(M):
    temp=heapq.heappop(A)
#    print(temp)
    heapq.heappush(A,temp//2+temp%2)
    
print(-sum(A))
### BUGGY CODE ###

h, w = map(int, input().split())
data = []
for i in range(h):
    s = input()
    data.append(s)
cnt_l, cnt_r, cnt_u, cnt_d = [[0] * w for _ in range(h)], [[0] * w for _ in range(h)], [[0] * w for _ in range(h)], [[0] * w for _ in range(h)]

for i in range(h):
    for j in range(w):
        if data[i][j] == "#":
            cnt_l[i][j] = 0
        else:
            cnt_l[i][j] = cnt_l[i][j - 1] + 1
    
    for j in range(w - 1, -1, -1):
        if data[i][j] == "#":
            cnt_r[i][j] = 0
        else:
            if j == w - 1:
                cnt_r[i][j] = 1
            else:
                cnt_r[i][j] = cnt_r[i][j + 1] + 1

for j in range(w):
    for i in range(h):
        if data[i][j] == "#":
            cnt_u[i][j] = 0
        else:
            cnt_u[i][j] = cnt_u[i - 1][j] + 1
    
    for i in range(h - 1, -1, -1):
        if data[i][j] == "#":
            cnt_d[i][j] = 0
        else:
            if i == h - 1:
                cnt_d[i][j] = 1
            else:
                cnt_d[i][j] = cnt_d[i + 1][j] + 1

ans = 0
for i in range(h):
    for j in range(w):
        total= cnt_l[i][j] + cnt_r[i][j] + cnt_u[i][j] + cnt_d[i][j] - 3
        ans = max(ans, total)

print(ans)

### FIXED CODE ###

h, w = map(int, input().split())
data = [list(input()) for _ in range(h)]

cnt_l, cnt_r, cnt_u, cnt_d = [[0] * w for _ in range(h)], [[0] * w for _ in range(h)], [[0] * w for _ in range(h)], [[0] * w for _ in range(h)]

for i in range(h):
    for j in range(w):
        if data[i][j] == "#":
            cnt_l[i][j] = 0
        else:
            cnt_l[i][j] = cnt_l[i][j - 1] + 1
    
        if data[i][w - j - 1] == "#":
            cnt_r[i][w - j - 1] = 0
        else:
            if j == 0:
                cnt_r[i][w - j - 1] = 1
            else:
                cnt_r[i][w - j - 1] = cnt_r[i][w - j] + 1

for j in range(w):
    for i in range(h):
        if data[i][j] == "#":
            cnt_u[i][j] = 0
        else:
            cnt_u[i][j] = cnt_u[i - 1][j] + 1

        if data[h - i - 1][j] == "#":
            cnt_d[h - i - 1][j] = 0
        else:
            if i == 0:
                cnt_d[h - i - 1][j] = 1
            else:
                cnt_d[h - i - 1][j] = cnt_d[h - i][j] + 1

ans = 0
for i in range(h):
    for j in range(w):
        total= cnt_l[i][j] + cnt_r[i][j] + cnt_u[i][j] + cnt_d[i][j] - 3
        ans = max(ans, total)

print(ans)
### BUGGY CODE ###

n, m, k = map(int, input().split())
ans = [0] * n
p = [{'T':[], 'B':[]} for _ in range(n)]
for _ in range(m):
    a, b = map(int, input().split())
    p[a-1]['T'].append(b)
    p[b-1]['T'].append(a)
    
for _ in range(k):
    c, d = map(int, input().split())
    p[c-1]['B'].append(d)
    p[d-1]['B'].append(c)

fl = []

for i, dt in enumerate(p):
    isContinue = False
    if i+1 in fl:
        continue
    tmp_fl = [i+1] + dt['T']
    rmn = [t for t in dt['T']]
    alr = [i+1]
    while not len(rmn) == 0:
        r = rmn.pop(0)
        alr.append(r)
        for nf in p[r-1]['T']:
            if not nf in tmp_fl:
                tmp_fl.append(nf)
            if not nf in rmn and not nf in alr:
                rmn.append(nf)
    fl.append(tmp_fl)
    
for i, dt in enumerate(p):
    l = [i+1]+ dt['T'] + dt['B']
    for f in fl:
        if i+1 in f:
            ans[i] = len([x for x in f if not x in l])
            

print(' '.join(map(str, ans)))


### FIXED CODE ###

import sys
input = sys.stdin.buffer.readline
from collections import deque

def main():
    N,M,K = map(int,input().split())
    friend = [[] for _ in range(N)]
    for _ in range(M):
        a,b = map(int,input().split())
        friend[a-1].append(b-1)
        friend[b-1].append(a-1)
        
    brock = [[] for _ in range(N)]
    for _ in range(K):
        c,d = map(int,input().split())
        brock[c-1].append(d-1)
        brock[d-1].append(c-1)
        
    parent = [-1 for _ in range(N)]
    group = [0 for _ in range(N)]
    
    for i in range(N):
        put = []
        if parent[i] == -1:
            q = deque([i])
            parent[i] = i
            while q:
                now = q.pop()
                put.append(now)
                for fol in friend[now]:
                    if parent[fol] == -1:
                        parent[fol] = i
                        q.append(fol)
            l = len(put)
            for num in put:
                group[num] = l-1
                
        else:
            continue

    for i in range(N):
        group[i] -= len(friend[i])
        for dis in brock[i]:
            if parent[i] == parent[dis]:
                group[i] -= 1
    
    print(*group)
    
if __name__ == "__main__":
    main()
### BUGGY CODE ###


num = input()
l = []
for i in range(0,int(num)):
    l.append(input())

cnt = []
for item in list(set(l)):
    cnt.append(l.count(item))

num_dict = dict(zip(list(set(l)),cnt))
max_v = max(num_dict.values())

keys = []

for word, num in num_dict.items():
    if num == max_v:
        keys.append(word)

for i in sorted(keys):
    print(i)

### FIXED CODE ###

from collections import Counter
N = int(input())
S = Counter(input() for _ in range(N))
m = max(S.values())
for v in sorted(k for k, v in S.items() if v == m):
	print(v)
### BUGGY CODE ###

# python3だとTLE,pypy3だとAC
def main():
    s = input()
    t = input()
    dp = [[0 for _ in range(len(t)+1)] for _ in range(len(s)+1)]
    for i, cs in enumerate(s, start=1):
        for j, ct in enumerate(t, start=1):
            if cs == ct:
                dp[i][j] = dp[i-1][j-1] + 1
            else:
                dp[i][j] = max(dp[i-1][j], dp[i][j-1])
    ans = ""
    i = len(s)
    j = len(t)
    while i > 0 and j > 0:
        if dp[i][j] == dp[i-1][j]:
            i -= 1
        elif dp[i][j] == dp[i][j-1]:
            j -= 1
        else:
            i -= 1
            j -= 1
            ans = s[i] + ans

    print(ans)


if __name__ == "__main__":
    main()


### FIXED CODE ###

# python3だとTLE,pypy3だとAC
def main():
    s = input()
    t = input()
    dp = [[0 for _ in range(len(t)+1)] for _ in range(len(s)+1)]
    for i, cs in enumerate(s, start=1):
        for j, ct in enumerate(t, start=1):
            if cs == ct:
                dp[i][j] = dp[i-1][j-1] + 1
            else:
                dp[i][j] = max(dp[i-1][j], dp[i][j-1])
    ans = ""
    i = len(s)
    j = len(t)
    while i > 0 and j > 0:
        if dp[i][j] == dp[i-1][j]:
            i -= 1
        elif dp[i][j] == dp[i][j-1]:
            j -= 1
        else:
            i -= 1
            j -= 1
            ans = s[i] + ans

    print(ans)


if __name__ == "__main__":
    main()
### BUGGY CODE ###

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

dp = [[False] * k for _ in range(n + 1)]
dp[0][0] = True
for i, e in enumerate(a, 1):
    for j in range(k):
        dp[i][j] = dp[i-1][j]

    for j in range(k - e):
        if dp[i-1][j]:
            dp[i][j+e] = True

dp2 = [[False] * k for _ in range(n + 1)]
dp2[0][0] = True
for i, e in enumerate(a[::-1], 1):
    for j in range(k):
        dp2[i][j] = dp2[i-1][j]

    for j in range(k - e):
        if dp2[i-1][j]:
            dp2[i][j+e] = True

ans = 0
for i, e in enumerate(a, 1):
    li = [j for j in range(k) if dp[i-1][j]]
    li2 = [j for j in range(k) if dp2[n-i][j]]

    j = len(li2) - 1
    mx = 0
    for e2 in li:
        while e2 + li2[j] >= k:
            j -= 1

        mx = max(mx, e2 + li2[j])

    if mx + e < k:
        ans += 1

print(ans)


### FIXED CODE ###

import numpy as np


def check(x):
    dp = np.zeros(k, np.bool)
    dp[0] = True
    for e in a[:x] + a[x+1:]:
        dp[e:] |= dp[:-e]

    return dp[-a[x]:].any()


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

a.sort()

lb = -1
ub = n
while ub - lb > 1:
    m = (lb + ub) // 2
    if check(m):
        ub = m
    else:
        lb = m

print(ub)