Buggy python submission (verdict: Runtime Error):
N,K = list(map(int, input().split(' ')))
d = {}
for i in range(N):
    S = str(input())[0]
    if S in d:
        d[S] += 1
    else:
        d[S] = 1
p = list(d.values())
if len(p) < K:
    print(0)
    sys.exit()
c = 0
while(len(p) >= K):
    c += 1
    sq = sorted(p, reverse=True)
    for i in range(K):
        sq[i] = sq[i] - 1
    p = [i for i in sq if i != 0]
print(c)


Fixed submission:
import sys
N,K = list(map(int, input().split(' ')))
d = {}
for i in range(N):
    S = str(input())[0]
    if S in d:
        d[S] += 1
    else:
        d[S] = 1
p = list(d.values())
if len(p) < K:
    print(0)
    sys.exit()
c = 0
while(len(p) >= K):
    c += 1
    sq = sorted(p, reverse=True)
    for i in range(K):
        sq[i] = sq[i] - 1
    p = [i for i in sq if i != 0]
print(c)

Buggy python submission (verdict: Runtime Error):
from heapq import heappush, heappop
import sys

N,K = list(map(int, input().split(' ')))
d = {}
for i in range(N):
    S = str(input())[0]
    if S in d:
        d[S] += 1
    else:
        d[S] = 1
p = list(d.values())
if len(p) < K:
    print(0)
    sys.exit(1)


Fixed submission:
import sys
N,K = list(map(int, input().split(' ')))
d = {}
for i in range(N):
    S = str(input())[0]
    if S in d:
        d[S] += 1
    else:
        d[S] = 1
p = list(d.values())
if len(p) < K:
    print(0)
    sys.exit()
c = 0
while(len(p) >= K):
    c += 1
    sq = sorted(p, reverse=True)
    for i in range(K):
        sq[i] = sq[i] - 1
    p = [i for i in sq if i != 0]
print(c)

Buggy python submission (verdict: Runtime Error):
from heapq import heappush, heappop
import sys

N,K = list(map(int, input().split(' ')))
d = {}
for i in range(N):
    S = str(input())[0]
    if S in d:
        d[S] += 1
    else:
        d[S] = 1
p = list(d.values())
if len(p) < K:
    print(0)
    sys.exit(1)

h = []
for i in p:
    heappush(h, i)

#while(len(h) > K):
a = len(h) - K
for _ in range(len(h) - K):
    k = heappop(h) + heappop(h)
    heappush(h, k)

print(min(h))


Fixed submission:
import sys
N,K = list(map(int, input().split(' ')))
d = {}
for i in range(N):
    S = str(input())[0]
    if S in d:
        d[S] += 1
    else:
        d[S] = 1
p = list(d.values())
if len(p) < K:
    print(0)
    sys.exit()
c = 0
while(len(p) >= K):
    c += 1
    sq = sorted(p, reverse=True)
    for i in range(K):
        sq[i] = sq[i] - 1
    p = [i for i in sq if i != 0]
print(c)

Buggy python submission (verdict: Runtime Error):
from heapq import heappush, heappop
import sys

N,K = list(map(int, input().split(' ')))
d = {}
for i in range(N):
    S = str(input())[0]
    if S in d:
        d[S] += 1
    else:
        d[S] = 1
p = list(d.values())
if len(p) < K:
    print(0)
    sys.exit(1)

h = []
for i in p:
    heappush(h, i)

while(len(h) > K):
    k = heappop(h) + heappop(h)
    heappush(h, k)

print(min(h))


Fixed submission:
import sys
N,K = list(map(int, input().split(' ')))
d = {}
for i in range(N):
    S = str(input())[0]
    if S in d:
        d[S] += 1
    else:
        d[S] = 1
p = list(d.values())
if len(p) < K:
    print(0)
    sys.exit()
c = 0
while(len(p) >= K):
    c += 1
    sq = sorted(p, reverse=True)
    for i in range(K):
        sq[i] = sq[i] - 1
    p = [i for i in sq if i != 0]
print(c)

Buggy python submission (verdict: Runtime Error):
from heapq import heappush, heappop
import sys

N,K = list(map(int, input().split(' ')))
d = {}
for i in range(N):
    S = str(input())[0]
    if S in d:
        d[S] += 1
    else:
        d[S] = 1
p = list(d.values())
if len(p) < K:
    print(0)
    sys.exit(1)

h = []
for i in p:
    heappush(h, i)

while(len(h) > K):
    k = heappop(h) + heappop(h)
    heappush(h, k)
    print(len(h))

print(min(h))


Fixed submission:
import sys
N,K = list(map(int, input().split(' ')))
d = {}
for i in range(N):
    S = str(input())[0]
    if S in d:
        d[S] += 1
    else:
        d[S] = 1
p = list(d.values())
if len(p) < K:
    print(0)
    sys.exit()
c = 0
while(len(p) >= K):
    c += 1
    sq = sorted(p, reverse=True)
    for i in range(K):
        sq[i] = sq[i] - 1
    p = [i for i in sq if i != 0]
print(c)

Buggy python submission (verdict: Runtime Error):
from heapq import heappush, heappop
import sys

N,K = list(map(int, input().split(' ')))
d = {}
for i in range(N):
    S = str(input())[0]
    if S in d:
        d[S] += 1
    else:
        d[S] = 1
p = list(d.values())
if len(p) < K:
    print(0)
    sys.exit(1)

h = []
for i in p:
    heappush(h, i)

while(len(h) > K):
    k = heappop(h) + heappop(h)
    heappush(h, k)

print(min(h))

Fixed submission:
import sys
N,K = list(map(int, input().split(' ')))
d = {}
for i in range(N):
    S = str(input())[0]
    if S in d:
        d[S] += 1
    else:
        d[S] = 1
p = list(d.values())
if len(p) < K:
    print(0)
    sys.exit()
c = 0
while(len(p) >= K):
    c += 1
    sq = sorted(p, reverse=True)
    for i in range(K):
        sq[i] = sq[i] - 1
    p = [i for i in sq if i != 0]
print(c)

Buggy python submission (verdict: Runtime Error):
from heapq import heappush, heappop
import sys

N,K = list(map(int, input().split(' ')))
d = {}
for i in range(N):
    S = str(input())[0]
    if S in d:
        d[S] += 1
    else:
        d[S] = 1
p = list(d.values())
if len(p) < K:
    print(0)
    sys.exit(1)

h = []
for i in p:
    heappush(h, i)

while(len(h) > K):
    k = heappop(h) + heappop(h)
    heappush(h, k)

print(min(h))


Fixed submission:
import sys
N,K = list(map(int, input().split(' ')))
d = {}
for i in range(N):
    S = str(input())[0]
    if S in d:
        d[S] += 1
    else:
        d[S] = 1
p = list(d.values())
if len(p) < K:
    print(0)
    sys.exit()
c = 0
while(len(p) >= K):
    c += 1
    sq = sorted(p, reverse=True)
    for i in range(K):
        sq[i] = sq[i] - 1
    p = [i for i in sq if i != 0]
print(c)

Buggy python submission (verdict: Runtime Error):
from heapq import heappush, heappop
import sys

N,K = list(map(int, input().split(' ')))
d = {}
for i in range(N):
    S = str(input())[0]
    if S in d:
        d[S] += 1
    else:
        d[S] = 1
p = list(d.values())
if len(p) < K:
    print(0)
    sys.exit(1)

h = []
for i in p:
    heappush(h, i)

while(len(h) != K):
    k = heappop(h) + heappop(h)
    heappush(h, k)

print(min(h))


Fixed submission:
import sys
N,K = list(map(int, input().split(' ')))
d = {}
for i in range(N):
    S = str(input())[0]
    if S in d:
        d[S] += 1
    else:
        d[S] = 1
p = list(d.values())
if len(p) < K:
    print(0)
    sys.exit()
c = 0
while(len(p) >= K):
    c += 1
    sq = sorted(p, reverse=True)
    for i in range(K):
        sq[i] = sq[i] - 1
    p = [i for i in sq if i != 0]
print(c)