You are given a following process. 

There is a platform with $n$ columns. $1 \times 1$ squares are appearing one after another in some columns on this platform. If there are no squares in the column, a square will occupy the bottom row. Otherwise a square will appear at the top of the highest square of this column. 

When all of the $n$ columns have at least one square in them, the bottom row is being removed. You will receive $1$ point for this, and all the squares left will fall down one row. 

You task is to calculate the amount of points you will receive.


-----Input-----

The first line of input contain 2 integer numbers $n$ and $m$ ($1 \le n, m \le 1000$) — the length of the platform and the number of the squares.

The next line contain $m$ integer numbers $c_1, c_2, \dots, c_m$ ($1 \le c_i \le n$) — column in which $i$-th square will appear.


-----Output-----

Print one integer — the amount of points you will receive.


-----Example-----
Input
3 9
1 1 2 2 2 3 1 2 3

Output
2



-----Note-----

In the sample case the answer will be equal to $2$ because after the appearing of $6$-th square will be removed one row (counts of the squares on the platform will look like $[2~ 3~ 1]$, and after removing one row will be $[1~ 2~ 0]$).

After the appearing of $9$-th square counts will be $[2~ 3~ 1]$, and after removing one row it will look like $[1~ 2~ 0]$.

So the answer will be equal to $2$.

Difficulty: EASY
Tags: Implementation
Expected Time Complexity: O(N^2)

Starter code:

Solutions:
while True:
	try:
		(n, m) = map(int, input().split())
		sqares = list(map(int, input().split()))
		colms = [0] * (n + 1)
		for i in range(m):
			colms[sqares[i]] += 1
		colms.sort()
		print(colms[1])
	except EOFError:
		break


(n, m) = [int(x) for x in input().split()]
list = [int(x) for x in input().split()]
new_lst = []
for item in range(1, n + 1):
	new_lst.append(list.count(item))
print(min(new_lst))


(n, m) = map(int, input().split())
a = list(map(int, input().split()))
t = [0] * n
for p in a:
	t[p - 1] += 1
print(min(t))


(n, m) = map(int, input().split())
grid = [0] * n
squares = map(int, input().split())
for s in squares:
	grid[s - 1] += 1
print(min(grid))


num_data = list(map(int, input().split(' ')))
square_data = list(map(int, input().split(' ')))
column_count = num_data[0]
number_count = num_data[1]
platform = [0] * column_count
score = 0
for i in square_data:
	col_idx = i - 1
	platform[col_idx] += 1
	all_fill = True
	for j in platform:
		all_fill = all_fill and j > 0
	if all_fill:
		score += 1
		for idx in range(0, column_count):
			platform[idx] -= 1
print(score)


(n, m) = input().split()
m = int(m)
n = int(n)
st = input()
data = list()
w = ''
for e in st:
	if e == ' ':
		data.append(int(w))
		w = ''
	else:
		w += e
data.append(int(w))
l = list([0] * n)
score = 0
for i in range(0, m):
	l[data[i] - 1] += 1
d = True
while d:
	for j in range(0, n):
		if l[j] == 0:
			d = False
	if not d:
		break
	score += 1
	for j in range(0, n):
		l[j] -= 1
print(score)


(n, m) = [int(x) for x in input().split()]
arr = [0] * n
for i in [int(x) for x in input().split()]:
	arr[i - 1] += 1
print(min(arr))


(n, _) = input().split()
a = [0] * int(n)
for c in input().split():
	a[int(c) - 1] += 1
print(min(a))


(n, m) = map(int, input().split())
columns = [0] * n
squares = [int(i) - 1 for i in input().split()]
rows = 0
for s in squares:
	columns[s] += 1
	if all((cnt > 0 for cnt in columns)):
		rows += 1
		columns = [cnt - 1 for cnt in columns]
print(rows)


(n, m) = list(map(int, input().split()))
array = list(map(int, input().split()))
b = [0 for i in range(n)]
for i in array:
	b[i - 1] += 1
c = 1001
for i in b:
	if c > i:
		c = i
print(c)


(a, b) = map(int, input().split())
n = list(map(int, input().split()))
i = 1
k = 1001
while i <= a:
	m = 0
	j = 0
	while j < len(n):
		if n[j] == i:
			m = m + 1
		j = j + 1
	k = min(k, m)
	i = i + 1
print(k)


z = int(input().split()[0])
a = list(map(int, input().split()))
print(min((a.count(i) for i in range(1, z + 1))))


(n, m) = map(int, input().split())
a = [0 for _ in range(n)]
for x in map(int, input().split()):
	a[x - 1] += 1
print(min(a))


(n, m) = map(int, input().split())
a = [0 for i in range(n)]
li = list(map(int, input().split()))
for i in li:
	a[i - 1] += 1
a.sort()
print(a[0])


(m, n) = map(int, input().split())
d = [0] * m
ans = 0
left = [m] * (n + 1)
for x in map(int, input().split()):
	x -= 1
	h = d[x]
	d[x] += 1
	left[h] -= 1
	if not left[h]:
		ans += 1
print(ans)


def li():
	return list(map(int, input().split()))
(n, m) = li()
a = li()
aa = [0] * n
for b in a:
	aa[b - 1] += 1
print(min(aa))


from collections import Counter as c
(n, m) = map(int, input().split())
l = input().split()
w = list(c(l).values())
print([0, min(w)][len(set(l)) == n])


(n, m) = map(int, input().split())
a = list(map(int, input().split()))
b = [0 for i in range(n + 1)]
c = 0
for i in a:
	b[i] += 1
	if 0 not in b[1:]:
		c += 1
		for j in range(1, len(b)):
			b[j] -= 1
print(c)


(n, m) = list(map(int, input().split()))
d = [0 for _ in range(n)]
for i in input().split():
	d[int(i) - 1] += 1
print(min(d))


(n, m) = map(int, input().split())
c = [0] * (n + 1)
for d in list(map(int, input().split())):
	c[d] += 1
print(min(c[1:]))


(columns, squares) = list(map(int, input().split()))
order = list(map(int, input().split()))
d = {}
for i in range(columns):
	d[i + 1] = 0
for i in order:
	d[i] += 1
print(min(d.values()))


(n, m) = map(int, input().split())
ar = list(map(int, input().split()))
r = m
for i in range(1, n + 1):
	r = min(r, ar.count(i))
print(r)


(n, k) = map(int, input().split())
l = [int(e) for e in input().split()]
print(min([l.count(i) for i in range(1, n + 1)]))


from collections import defaultdict
(n, m) = list(map(int, input().split()))
cnt = defaultdict(int)
for el in list(map(int, input().split())):
	cnt[el] += 1
res = float('inf')
for i in range(1, n + 1):
	res = min(res, cnt[i])
print(res)


(k, n) = map(int, input().split())
l = list(map(int, input().split()))
s = set(l)
m = 10 ** 10
if len(s) != k:
	print(0)
else:
	for i in s:
		x = l.count(i)
		if x < m:
			m = x
	print(m)


ch1 = input()
ch2 = input()
l1 = ch1.split()
l2 = ch2.split()
m = 0
k = [0] * int(l1[0])
for i in l2:
	k[int(i) - 1] += 1
min = k[0]
for i in k:
	if min > i:
		min = i
print(min)


(n, m) = map(int, input().split())
cnt = [0 for i in range(n + 1)]
cnt[0] = 1005
for i in list(map(int, input().split())):
	cnt[i] += 1
print(min(cnt))


from collections import Counter
(s, m) = input().split()
c = Counter(list(map(int, input().split())))
print(min([c[x] for x in range(1, int(s) + 1)]))


(n, m) = map(int, input().split())
d = dict()
for i in range(1, n + 1):
	d[i] = 0
l = list(map(int, input().split()))
for i in l:
	d[i] += 1
l = list(d.values())
print(min(l))


(n, m) = [int(i) for i in input().split()]
l = [0 for i in range(n)]
o = [int(i) for i in input().split()]
for i in o:
	l[i - 1] += 1
score = 0
while not 0 in l:
	l = [i - 1 for i in l]
	score += 1
print(score)


(n, m) = map(int, input().split())
a = list(map(int, input().split()))
x = [0] * n
for i in range(m):
	x[a[i] - 1] += 1
print(min(x))


from sys import stdin, stdout
a = [0] * int(stdin.readline().split()[0])
for i in stdin.readline().split():
	a[int(i) - 1] += 1
stdout.write(str(min(a)))


(n, m) = map(int, input().strip().split())
arr = list(map(int, input().split()))
mn = 1004
count = [0] * (n + 1)
i = 0
while i < m:
	count[arr[i]] += 1
	i += 1
i = 1
while i <= n:
	if count[i] < mn:
		mn = count[i]
	i += 1
print(mn)


def solve(n, m, c):
	b = [0] * n
	for i in c:
		b[i - 1] += 1
	return min(b)

def main():
	(n, m) = list(map(int, input().split()))
	c = list(map(int, input().split()))
	print(solve(n, m, c))
main()


n = list(map(int, input().split()))
a = list(map(int, input().split()))
s = []
points = 0
for i in range(n[0]):
	s.append(0)
for i in range(n[1]):
	s[a[i] - 1] += 1
	if 0 not in s:
		for i in range(n[0]):
			s[i] -= 1
		points += 1
print(points)


(m, n) = tuple(map(int, input().split()))
d = tuple(map(int, input().split()))
print(min((d.count(i) for i in range(1, m + 1))))


[n, m] = [int(i) for i in input().split(' ')]
a = [int(j) for j in input().split(' ')]
plat = []
for j in range(n):
	plat.append(0)
for i in a:
	plat[i - 1] += 1
min = plat[0]
for x in range(len(plat)):
	if plat[x] < min:
		min = plat[x]
print(min)


(n, m) = map(int, input().split())
Platform = [0 for i in range(n)]
l = [*map(int, input().split())]
for i in l:
	Platform[i - 1] += 1
print(min(Platform))


(n, m) = map(int, input().split())
a = input().split()
print(min((a.count(i) for i in set(a))) if len(set(a)) == n else 0)


(m, n) = [int(x) for x in input().split()]
cols = [int(x) for x in input().split()]
ans = 0
arr = [0] * m
for i in cols:
	arr[i - 1] += 1
	flag = True
	for index in range(m):
		if arr[index] > 0:
			pass
		else:
			flag = False
			break
	if flag:
		ans += 1
		for ii in range(m):
			arr[ii] -= 1
print(ans)


import sys, math, itertools
from collections import Counter, deque, defaultdict
from bisect import bisect_left, bisect_right
from heapq import heappop, heappush, heapify, nlargest
from copy import deepcopy
mod = 10 ** 9 + 7
INF = float('inf')

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

def inpl():
	return list(map(int, sys.stdin.readline().split()))

def inpl_1():
	return list(map(lambda x: int(x) - 1, sys.stdin.readline().split()))

def inps():
	return sys.stdin.readline()

def inpsl(x):
	tmp = sys.stdin.readline()
	return list(tmp[:x])

def err(x):
	print(x)
	exit()
(n, m) = inpl()
cnt = [0] * n
c = inpl_1()
for x in c:
	cnt[x] += 1
print(min(cnt))


col = input().split(' ')
square = input().split(' ')
array = []
for i in range(int(col[0])):
	array.append(0)
for x in square:
	array[int(x) - 1] += 1
small = 99999999
for b in array:
	if b < small:
		small = b
print(small)


import collections
(n, m) = map(int, input().split())
a = collections.Counter(list(map(int, input().split())))
if len(a) < n:
	print(0)
else:
	print(min(a.values()))


(n, m) = map(int, input().split())
l = list(map(int, input().split()))
p = []
for i in range(1, n + 1):
	x = l.count(i)
	p.append(x)
print(min(p))


(n, m) = list(map(int, input().split()))
c = list(map(int, input().split()))
b = []
for i in range(1, n + 1):
	b.append(c.count(i))
print(min(b))


def check_bottom(pilhas):
	for pilha in pilhas:
		if pilhas[pilha] == 0:
			return False
	return True
(col, data) = map(int, input().split())
squares = list(map(int, input().split()))
(pilhas, pontos) = ({}, 0)
for c in range(col):
	pilhas[c + 1] = 0
for square in squares:
	pilhas[square] += 1
	if check_bottom(pilhas):
		for pilha in pilhas:
			pilhas[pilha] -= 1
		pontos += 1
print(pontos)


(y, x) = [*map(int, input().split())]
o = [*map(int, input().split())]
print(min([o.count(_) for _ in range(1, y + 1)]))


(n, m) = map(int, input().split())
a = list(map(int, input().split()))
ans = 0
b = []
for i in range(n):
	b.append(0)
for i in range(m):
	b[a[i] - 1] += 1
	kill = True
	for j in range(n):
		if b[j] == 0:
			kill = False
			break
	if kill == True:
		ans += 1
		for j in range(n):
			b[j] -= 1
print(ans)


(n, k) = map(int, input().split())
arr = list(map(int, input().split()))
l = []
for b in range(n):
	l.append(0)
for i in range(k):
	l[arr[i] - 1] += 1
print(min(l))


def solve(n, m, arr):
	mn = 1245
	for i in range(1, n + 1):
		cnt = 0
		for j in range(m):
			if arr[j] == i:
				cnt += 1
		mn = min(cnt, mn)
	return mn

def main():
	(n, m) = input().split()
	(n, m) = (int(n), int(m))
	arr = input().split()
	for i in range(m):
		arr[i] = int(arr[i])
	print(solve(n, m, arr))
main()


from sys import stdin, stdout
from random import randrange
sze = 10 ** 3 + 10
(n, m) = map(int, stdin.readline().split())
values = list(map(int, stdin.readline().split()))
cnt = [0 for i in range(sze)]
INF = float('inf')
ans = 0
for v in values:
	cnt[v] += 1
	mn = INF
	for i in range(1, n + 1):
		mn = min(mn, cnt[i])
	ans += mn
	for i in range(1, n + 1):
		cnt[i] -= mn
stdout.write(str(ans))


(n, m) = map(int, input().split())
a = [0] * n
l = list(map(int, input().split()))
points = 0

def all():
	for i in a:
		if i - points <= 0:
			return False
	return True
for x in l:
	x -= 1
	a[x] += 1
	if all():
		points += 1
print(points)


(a, b) = map(int, input().split())
k = 0
l = list(map(int, input().split()))
l.sort()
a1 = []
for i in range(1, a + 1):
	b = l.count(i)
	a1.append(b)
print(min(a1))


(n, m) = list(map(int, input().strip().split()))
arr = list(map(int, input().strip().split()))
rslt = [0] * n
for x in arr:
	rslt[x - 1] += 1
print(min(rslt))


(n, m) = input().split()
byte_array = input().split(' ')
tetris = []
n = int(n)
for i in range(0, n + 1):
	tetris.append(0)
for i in byte_array:
	tetris[int(i)] += 1
minim = 10000
for i in range(1, n + 1):
	minim = min(tetris[i], minim)
print(minim)


(m, n) = [int(x) for x in input().split()]
row = [0] * m
tetris = [int(x) for x in input().split()]
for i in tetris:
	row[i - 1] += 1
print(min(row))


(n, m) = map(int, input().split())
lim = list(map(int, input().split()))
dicn = dict()
for i in range(1, n + 1):
	dicn[i] = lim.count(i)
print(min(dicn.values()))


(n, m) = map(int, input().split())
e = list(map(int, input().split()))
q = [0] * n
for i in range(0, m):
	q[e[i] - 1] += 1
print(min(q))


[columnsNumber, squareNumber] = list(map(int, input().split()))
squares = list(map(int, input().split()))
scores = 0
columns = [[] for column in range(columnsNumber)]
for square in squares:
	columns[square - 1].append(1)
columnsLengths = [len(column) for column in columns]
scores = min(columnsLengths)
print(scores)


(n, m) = map(int, input().split())
c = sorted(list(map(int, input().split())))
b = list()
if len(set(c)) != n:
	print(0)
else:
	count = 1
	for i in range(m - 1):
		if c[i] == c[i + 1]:
			count += 1
		else:
			b.append(count)
			count = 1
	b.append(count)
	print(min(b))


import sys
input = sys.stdin.readline

def swaparr(arr, a, b):
	temp = arr[a]
	arr[a] = arr[b]
	arr[b] = temp

def gcd(a, b):
	if b == 0:
		return a
	return gcd(b, a % b)

def nCr(n, k):
	if k > n - k:
		k = n - k
	res = 1
	for i in range(k):
		res = res * (n - i)
		res = res / (i + 1)
	return int(res)

def upper_bound(a, x, lo=0):
	hi = len(a)
	while lo < hi:
		mid = (lo + hi) // 2
		if a[mid] < x:
			lo = mid + 1
		else:
			hi = mid
	return lo

def primefs(n):
	primes = {}
	while n % 2 == 0 and n > 0:
		primes[2] = primes.get(2, 0) + 1
		n = n // 2
	for i in range(3, int(n ** 0.5) + 2, 2):
		while n % i == 0 and n > 0:
			primes[i] = primes.get(i, 0) + 1
			n = n // i
	if n > 2:
		primes[n] = primes.get(n, 0) + 1
	return primes

def power(x, y, p):
	res = 1
	x = x % p
	if x == 0:
		return 0
	while y > 0:
		if y & 1 == 1:
			res = res * x % p
		y = y >> 1
		x = x * x % p
	return res

def swap(a, b):
	temp = a
	a = b
	b = temp
	return (a, b)

def find(x, link):
	p = x
	while p != link[p]:
		p = link[p]
	while x != p:
		nex = link[x]
		link[x] = p
		x = nex
	return p

def union(x, y, link, size):
	x = find(x, link)
	y = find(y, link)
	if size[x] < size[y]:
		(x, y) = swap(x, y)
	if x != y:
		size[x] += size[y]
		link[y] = x

def sieve(n):
	prime = [True for i in range(n + 1)]
	p = 2
	while p * p <= n:
		if prime[p] == True:
			for i in range(p * p, n + 1, p):
				prime[i] = False
		p += 1
	return prime
MAXN = int(1000000.0 + 5)

def spf_sieve():
	spf[1] = 1
	for i in range(2, MAXN):
		spf[i] = i
	for i in range(4, MAXN, 2):
		spf[i] = 2
	for i in range(3, ceil(MAXN ** 0.5), 2):
		if spf[i] == i:
			for j in range(i * i, MAXN, i):
				if spf[j] == j:
					spf[j] = i

def factoriazation(x):
	ret = {}
	while x != 1:
		ret[spf[x]] = ret.get(spf[x], 0) + 1
		x = x // spf[x]
	return ret

def int_array():
	return list(map(int, input().strip().split()))

def str_array():
	return input().strip().split()
MOD = int(1000000000.0) + 7
CMOD = 998244353
INF = float('inf')
NINF = -float('inf')
(n, m) = int_array()
a = int_array()
array = [0] * n
for i in a:
	array[i - 1] += 1
print(min(array))


(n, m) = list(map(int, input().split()))
l = list(map(int, input().split()))
mas = []
for i in range(n):
	mas.append(0)
for i in l:
	mas[i - 1] += 1
print(min(mas))


r = lambda : map(int, input().split())
(n, _) = r()
c = list(r())
print(min(map(c.count, range(1, n + 1))))


(n, m) = map(int, input().split())
c = list(map(int, input().split()))
p = [0] * n
for i in range(len(c)):
	p[c[i] - 1] = p[c[i] - 1] + 1
print(min(p))


t = [int(x) for x in input().split(' ')]
u = [int(x) for x in input().split(' ')]
a = t[0]
b = t[1]
y = 0
c = u.count(u[0])
i = 0
for i in range(a):
	y = u.count(i + 1)
	if y < c:
		c = y
print(c)


k = int(input().split(' ')[0])
s = input().split(' ')
m = []
for i in range(k):
	m.append(int(s.count(str(i + 1))))
print(min(m))


a = input().split()
arr = input().split()
arr = list(map(int, arr))
score = 0
flag = True
while flag:
	for i in range(1, int(a[0]) + 1):
		try:
			index = arr.index(i)
		except ValueError:
			index = -1
		if index == -1:
			flag = False
			break
		else:
			arr.pop(index)
	score += 1
if score != 0:
	print(score - 1)
else:
	print(score)


(n, m) = map(int, input().split())
l = [0] * (n + 1)
for i in tuple(map(int, input().split())):
	l[i] += 1
print(min(l[1:]))


import sys
import math
get_string = lambda : sys.stdin.readline().strip()
get_int_list = lambda : list(map(int, sys.stdin.readline().strip().split()))
get_intList_from_str = lambda : list(map(int, list(sys.stdin.readline().strip())))
get_charList_from_str = lambda : list(sys.stdin.readline().strip())
get_char_list = lambda : sys.stdin.readline().strip().split()
get_int = lambda : int(sys.stdin.readline())
pt = lambda x: sys.stdout.write(str(x))
(n, m) = get_int_list()
column = [0] * n
inputX = get_int_list()
for i in inputX:
	column[i - 1] += 1
print(min(column))


inputint = lambda : map(int, input().split())
(n, m) = inputint()
a = list(inputint())
L = [0] * n
for i in a:
	L[i - 1] += 1
print(min(L))


s = input().split()
n = int(s[0])
m = int(s[1])
a = input().split()
t = m
for i in range(1, n + 1):
	if t > a.count(str(i)):
		t = a.count(str(i))
print(t)


i = 0
x = input().split(' ')
n = int(x[0])
m = int(x[1])
c = input().split(' ')
r = [0] * n
while i < m:
	if int(c[i]) > 0:
		r[int(c[i]) - 1] = r[int(c[i]) - 1] + 1
	i = i + 1
i = 0
minimum = r[0]
while i < len(r):
	if minimum > r[i]:
		minimum = r[i]
	i = i + 1
print(minimum)


inp = lambda : list(map(int, input().split()))
(n, m) = inp()
ds = [0] * (n + 1)
for num in inp():
	ds[num] += 1
print(min(ds[1:n + 1]))


(n, m) = map(int, input().split())
daf1 = list(map(int, input().split()))
daf2 = dict()
for i in range(n):
	daf2[i + 1] = 0
for i in daf1:
	if i in daf2.keys():
		daf2[i] += 1
print(min(daf2.values()))


firstLine = input().strip().split(' ')
numCols = int(firstLine[0])
numSquares = int(firstLine[1])
squareSupply = list(map(int, input().strip().split(' ')))
gameBoard = []
for i in range(numCols):
	gameBoard.append([])
score = 0
done = False
for i in range(len(squareSupply)):
	intendedCol = squareSupply[i] - 1
	gameBoard[intendedCol].append(True)
shortestColLength = len(gameBoard[0])
for i in range(numCols):
	if len(gameBoard[i]) < shortestColLength:
		shortestColLength = len(gameBoard[i])
print(shortestColLength)


b = []
(x, y) = map(int, input().split())
for i in range(x):
	b.append(0)
z = list(map(int, input().split()))
for i in range(y):
	b[z[i] - 1] += 1
print(min(b))


(n, m) = map(int, input().split())
blks = list(map(int, input().split()))
cnt = [0] * n
for blk in blks:
	cnt[blk - 1] += 1
cntMin = m
for subTot in cnt:
	cntMin = min(cntMin, subTot)
print(cntMin)


I = lambda : int(input())
IL = lambda : list(map(int, input().split()))
(n, m) = IL()
C = IL()
print(min((C.count(i + 1) for i in range(n))))


yo = list(map(int, input().split()))
n = yo[0]
m = yo[1]
ro = list(map(int, input().split()))
arr = []
for i in range(n):
	arr.append(0)
for j in ro:
	arr[j - 1] += 1
mini = arr[0]
minind = 0
for i in range(n):
	if arr[i] < mini:
		mini = arr[i]
		minind = i
print(mini)


import sys
(n, m) = map(int, sys.stdin.readline().split(' '))
blocks = list(map(int, sys.stdin.readline().split(' ')))
platform = (n + 1) * [0]
for i in range(m):
	platform[blocks[i]] += 1

def tetris(platform):
	score = 0
	while True:
		for x in range(1, n + 1):
			if platform[x] > 0:
				platform[x] -= 1
			else:
				return score
		score += 1
print(tetris(platform))


def main():
	(n, m) = map(int, input().split())
	liste = [int(x) for x in input().split()]
	mm = liste.count(n)
	score = liste.count(n)
	maxx = 0
	for loop in range(1, n + 1):
		if liste.count(loop) < mm:
			if abs(liste.count(loop) - mm) > maxx:
				maxx = abs(liste.count(loop) - mm)
		if liste.count(loop) == 0:
			return 0
	return score - maxx
print(main())


(n, m) = [int(w) for w in input().split()]
cnt = [0] * n
for val in [int(w) for w in input().split()]:
	cnt[val - 1] += 1
print(min(cnt))


(n, m) = map(int, input().split())
a = [0] * n
for i in map(int, input().split()):
	a[i - 1] += 1
print(min(a))


(n, m) = map(int, input().split())
data = list(map(int, input().split()))
tetrix = [0 for i in range(n)]
for i in data:
	tetrix[i - 1] += 1
print(min(tetrix))


(n, m) = map(int, input().split())
li = []
for x in input().split():
	li.append(int(x))
print(min((li.count(i) for i in range(1, n + 1))))


from collections import Counter
(n, m) = map(int, input().split())
c = Counter(map(int, input().split()))
if len(c.keys()) < n:
	print(0)
else:
	print(min([c[x] for x in c.keys()]))


from collections import Counter
(n, t) = [*map(int, input().split())]
list1 = [*map(int, input().split())]
set1 = set(list1)
if n == len(set1):
	print(Counter(list1).most_common()[-1][1])
else:
	print('0')


(n, m) = map(int, input().split())
c = list(map(int, input().split()))
print(min((c.count(x + 1) for x in range(n))))


(a, b) = map(int, input().split())
s = list(map(int, input().split()))
d = [0 for i in range(a)]
for i in s:
	d[i - 1] += 1
print(min(d))


a = input().split(' ')
(n, m) = (int(a[0]), int(a[1]))
a = input().split(' ')
a = list((int(x) for x in a))
res = dict(([x, 0] for x in range(1, n + 1)))
for x in a:
	res[x] += 1
ans = int(1e+16)
for x in res:
	ans = min(ans, res[x])
print(ans)


import math, string, itertools, fractions, heapq, collections, re, array, bisect, sys, copy, functools
import random
sys.setrecursionlimit(10 ** 7)
inf = 10 ** 20
eps = 1.0 / 10 ** 10
mod = 10 ** 9 + 7
dd = [(-1, 0), (0, 1), (1, 0), (0, -1)]
ddn = [(-1, 0), (-1, 1), (0, 1), (1, 1), (1, 0), (1, -1), (0, -1), (-1, -1)]

def LI():
	return list(map(int, sys.stdin.readline().split()))

def LLI():
	return [list(map(int, l.split())) for l in sys.stdin.readlines()]

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

def LF():
	return [float(x) for x in sys.stdin.readline().split()]

def LS():
	return sys.stdin.readline().split()

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

def F():
	return float(sys.stdin.readline())

def S():
	return input()

def pf(s):
	return print(s, flush=True)

def pe(s):
	return print(str(s), file=sys.stderr)

def main():
	(n, m) = LI()
	c = collections.Counter(LI())
	r = min((c[i] for i in range(1, n + 1)))
	return r
print(main())


(n, k) = map(int, input().split())
arr = list(map(int, input().split()))
l = []
yes = 0
points = 0
for b in range(n + 1):
	l.append(0)
for i in range(k):
	for a in range(1, n + 1):
		if arr[i] == a:
			l[a - 1] = l[a - 1] + 1
			break
for d in range(k):
	for c in range(n):
		if l[c] >= 1:
			yes = yes + 1
		else:
			break
	if yes == n:
		points = points + 1
		yes = yes - n
		for e in range(n):
			l[e] = l[e] - 1
	else:
		break
print(points)


line1 = input()
temp1 = line1.split(' ')
n = int(temp1[0])
m = int(temp1[1])
Mat = [0] * n
line2 = input()
temp2 = line2.split(' ')
points = 0
for i in range(m):
	index = int(temp2[i]) - 1
	Mat[index] = Mat[index] + 1
	if sorted(Mat)[0] != 0:
		for i in range(len(Mat)):
			Mat[i] = Mat[i] - 1
		points += 1
print(points)


(n, m) = map(int, input().split())
l = list(map(int, input().split()))
d = {}
for i in range(1, n + 1):
	d[i] = 0
for i in l:
	d[i] += 1
d = dict(sorted(d.items(), key=lambda x: x[1]))
for i in d:
	print(d[i])
	break


(n, m) = map(int, input().split())
out = [0] * n
score = 0
for col in list(map(int, input().split())):
	col -= 1
	out[col] += 1
	flag = True
	for elem in out:
		if elem == 0:
			flag = False
	if flag:
		for i in range(n):
			out[i] -= 1
		score += 1
print(score)


(n, m) = [int(x) for x in input().split()]
a = [0] * n
xs = [int(x) for x in input().split()]
r = 0
for x in xs:
	a[x - 1] += 1
	if min(a) == 1:
		r += 1
		a = [y - 1 for y in a]
print(r + 5 - 5)


import sys
from collections import Counter
[n, m] = map(int, sys.stdin.readline().strip().split())
cis = list(map(int, sys.stdin.readline().strip().split()))
c = Counter(cis)
if len(c.keys()) < n:
	print(0)
else:
	print(min(c.values()))


(n, m) = map(int, input().split())
c = list(map(int, input().split()))
ls = [0] * n
for cc in c:
	ls[cc - 1] += 1
print(min(ls))


(rong, sl) = map(int, input().split())
play = list(map(int, input().split()))
rs = sl
for i in range(1, rong + 1):
	dem = play.count(i)
	if dem < rs:
		rs = dem
print(rs)


import sys
import math

def scan(input_type='int'):
	return list(map(int, sys.stdin.readline().strip().split()))

def solution():
	(n, k) = scan()
	a = scan()
	b = {}
	for i in a:
		if i in b:
			b[i] += 1
		else:
			b[i] = 1
	a = [0] * n
	for i in b:
		a[i - 1] = b[i]
	print(min(a))
solution()


(n, m) = list(map(int, input().strip().split()))
lis = list(map(int, input().strip().split()))
res = [0 for i in range(n)]
count = 0
for i in lis:
	res[int(i) - 1] += 1
	if 0 not in res:
		count += 1
		for j in range(n):
			res[j] -= 1
print(count)


(n, useless) = list(map(int, input().split()))
arr = list(map(int, input().split()))
for x in range(1, n + 1):
	if x not in arr:
		print(0)
		break
else:
	print(arr.count(min(arr, key=lambda x: arr.count(x))))


(n, m) = map(int, input().split())
c = list(map(int, input().split()))
sqrs = {}
for i in range(n):
	sqrs[i + 1] = 0
t = pnts = 0
for sq in c:
	sqrs[sq] += 1
	if t not in sqrs.values():
		t += 1
		pnts += 1
print(pnts)


(n, m) = map(int, input().split())
arr = [0 for i in range(n)]
temp_arr = list(map(int, input().split()))
for i in temp_arr:
	arr[i - 1] += 1
print(min(arr))


man = [int(x) for x in input().split()]
maxi = [int(x) for x in input().split()]
yolo = []
for i in range(1, man[0] + 1):
	yolo.append(maxi.count(i))
print(min(yolo))


(n, m) = map(int, input().split())
c = list(map(int, input().split()))
count = []
for i in range(0, n):
	count.append(0)
for brick in c:
	count[brick - 1] += 1
ans = min(count)
print(ans)


input_line1 = input()
input_line2 = input()
tetris_list = input_line2.split(' ')
info_list = input_line1.split(' ')
col = int(info_list[0])
max = int(info_list[1])
out_list = []
for i in range(col):
	out_list.append(tetris_list.count(str(i + 1)))
print(min(out_list))


(n, m) = map(int, input().split())
l = list(map(int, input().split()))
d = dict()
if len(set(l)) < n:
	print(0)
else:
	for i in range(m):
		d.setdefault(l[i], 0)
		d[l[i]] += 1
	min1 = 999999999
	for i in d.values():
		if i < min1:
			min1 = i
	print(min1)


import atexit
import io
import sys
_INPUT_LINES = sys.stdin.read().splitlines()
input = iter(_INPUT_LINES).__next__
_OUTPUT_BUFFER = io.StringIO()
sys.stdout = _OUTPUT_BUFFER

@atexit.register
def write():
	sys.__stdout__.write(_OUTPUT_BUFFER.getvalue())

def main():
	(n, m) = [int(x) for x in input().split()]
	c = [int(x) for x in input().split()]
	print(min((c.count(x) for x in range(1, n + 1))))

def __starting_point():
	main()
__starting_point()


c_s = list(map(int, input().strip().split()))
n = list(map(int, input().strip().split()))
ans = [0] * c_s[0]
count = 0
for i in n:
	ans[i - 1] += 1
count = min(ans)
print(count)


from collections import Counter
(n, m) = [int(i) for i in input().split()]
a = [int(i) for i in input().split()]
M = [0 for i in range(n)]
for i in range(m):
	M[a[i] - 1] += 1
print(min(M))


(x, m) = map(int, input().split())
l = list(map(int, input().split()))
l1 = [0] + [int(0) for i in range(x)]
for i in l:
	l1[i] += 1
print(min(l1[1:]))


(n, m) = map(int, input().split())
l = [0] * n
inpu = input()
inp = [int(x) for x in inpu.split()]
for i in range(m):
	l[inp[i] - 1] += 1
mini = 1000
for i in range(n):
	if mini > l[i]:
		mini = l[i]
print(mini)


import collections
(n, m) = [int(i) for i in input().split()]
numbers = [int(i) for i in input().split()]
dict1 = collections.Counter(numbers)
list1 = list(dict1.keys())
list1.sort()
if list1 != [i for i in range(1, n + 1)]:
	print(0)
else:
	print(min(dict1.values()))


(n, m) = map(int, input().split())
mas = list(map(int, input().split()))
mn = 1001
for i in range(1, n + 1):
	if mas.count(i) < mn:
		mn = mas.count(i)
print(mn)


(n, m) = list(map(int, input().split()))
arr = [0 for i in range(n)]
sq = list(map(int, input().split()))
for c in sq:
	arr[c - 1] += 1
print(min(arr))


(n, m) = (int(i) for i in input().split())
tab = [0] * n
for i in [int(j) for j in input().split()]:
	tab[i - 1] += 1
print(min(tab))


(n, m) = map(int, input().split())
c = list(map(int, input().split()))
counts = [0] * n
for i in range(n):
	counts[i] = c.count(i + 1)
print(min(counts))


c = [int(x) for x in input().split()]
k = c[0]
n = c[1]
b = [0] * 1001
a = [int(x) for x in input().split()]
for i in range(n):
	b[a[i] - 1] += 1
min1 = 1000
for i in range(k):
	if b[i] < min1:
		min1 = b[i]
print(min1)


a = input().split()
b = [0 for i in range(int(a[0]))]
c = list(map(int, input().split()))
for j in range(int(a[1])):
	b[c[j] - 1] += 1
print(str(min(b)))


import sys
import os
import math
import re
(n, m) = map(int, input().split())
data = list(map(int, input().split()))
info = [0] * n
totalpoints = 0
slot = 0
for val in data:
	info[val - 1] += 1
	if all((j > slot for j in info)):
		totalpoints += 1
		slot += 1
print(totalpoints)


(n, m) = input().split()
n = int(n)
m = int(m)
c = input().split()
plat = [0] * n
for i in c:
	i = int(i)
	plat[i - 1] = plat[i - 1] + 1
min = min(plat)
for x in range(len(plat)):
	plat[x] = plat[x] - min
print(min)


a = list(map(int, input().split()))
n = a[0]
m = a[1]
c = list(map(int, input().split()))
k = []
for i in range(n):
	k.append(0)
for i in c:
	k[i - 1] += 1
print(min(k))


(n, m) = input().split()
n = int(n)
m = int(m)
c = input().split()
c = [int(x) for x in c]
c.sort()
foo = []
for i in range(n):
	foo.append(0)
for i in c:
	foo[i - 1] += 1
print(min(foo))


(n, m) = map(int, input().split())
massive_c = list(map(int, input().split()))
least_num = []
if len(set(massive_c)) < n:
	least_num = 0
else:
	for i in range(1, n + 1):
		temp_least_num = massive_c.count(i)
		least_num = least_num or temp_least_num
		if temp_least_num < least_num:
			least_num = temp_least_num
print(least_num)


(n, m) = map(int, input().split())
a = [0] * n
b = list(map(int, input().split()))
for x in b:
	a[x - 1] += 1
print(min(a))


(n, m) = list(map(int, input().split()))
list1 = []
for i in range(n):
	list1.append(0)
inp = list(map(int, input().split()))
for i in range(m):
	into = inp[i]
	x = list1[into - 1]
	list1[into - 1] = x + 1
print(min(list1))


(n, m) = input().split()
s = [0] * int(n)
for i in input().split():
	s[int(i) - 1] += 1
print(min(s))


(n, m) = [int(s) for s in input().split()]
count = n * [0]
for cs in input().split():
	count[int(cs) - 1] += 1
print(min(count))


(n, m) = [int(x) for x in input().split()]
ms = [int(x) for x in input().split()]
st = [0] * n
for x in ms:
	st[x - 1] += 1
print(min(st))


(n, m) = map(int, input().split())
a = list(map(int, input().split()))
mi = 10 ** 9
for i in range(1, n + 1):
	mi = min(mi, a.count(i))
print(mi)


(n, m) = [int(i) for i in input().split()]
a = [int(i) for i in input().split()]
d = [0 for i in range(n)]
for i in a:
	d[i - 1] += 1
print(min(d))


s = input().split()
(n, m) = (int(s[0]), int(s[1]))
c = list(map(int, input().split()))
min_cnt = -1
for i in range(1, n + 1):
	cnt = c.count(i)
	if min_cnt == -1 or cnt < min_cnt:
		min_cnt = cnt
print(min_cnt)


(n, m) = map(int, input().split())
l = list(map(int, input().split()))
w = []
for i in range(n):
	w.append(l.count(i + 1))
w.sort()
print(w[0])


(n, m) = input().split()
n = int(n)
m = int(m)
s = input().split()
count = dict()
for i in s:
	count[i] = count.get(i, 0) + 1
b = []
a = 0
for (k, v) in count.items():
	a = a + 1
if a == n:
	for v in count.values():
		b.append(v)
	print(min(b))
else:
	print('0')


(n, m) = map(int, input().strip().split())
c = list(map(int, input().strip().split()))
filled = [0] * n
for x in c:
	filled[x - 1] += 1
print(min(filled))


(x, y) = map(int, input().split())
a = list(map(int, input().split()))
d = {}
k = 0
t = 0
for i in range(x):
	d[i + 1] = 0
for i in range(len(a)):
	m = 0
	d[a[i]] += 1
	for k in range(x):
		if d[k + 1] != 0:
			continue
		else:
			m = 1
			break
	if m == 0:
		t = t + 1
		for j in range(x):
			d[j + 1] += -1
print(t)


alph = 'abcdefghijklmnopqrstuvwxyz'
(n, m) = map(int, input().split())
c = list(map(int, input().split()))
arr = []
for i in range(n):
	arr.append(c.count(i + 1))
print(min(arr))


(n, m) = map(int, input().strip().split(' '))
L = list(map(int, input().split()))
T = [0] * (n + 1)
for i in range(m):
	T[L[i]] += 1
T = sorted(T)
T.pop(0)
print(T[0])


GI = lambda : int(input())
GIS = lambda : map(int, input().split())
LGIS = lambda : list(GIS())

def main():
	(n, m) = GIS()
	d = [0] * n
	for x in GIS():
		d[x - 1] += 1
	print(min(d))
main()


(n, m) = input().split()
n = int(n)
m = int(m)
s = list(map(lambda x: int(x), input().split()))
res = [0] * n
for elem in s:
	res[elem - 1] += 1
print(min(res))


inp = input().split()
n = int(inp[0])
m = int(inp[1])
C = input().split()
T = [0 for i in range(0, n)]
p = 0
for c in C:
	c = int(c)
	T[c - 1] += 1
	if T.count(0) == 0:
		p += 1
		for i in range(0, n):
			T[i] -= 1
print(p)


import collections
(n, blocks) = map(int, input().split())
dick = collections.defaultdict(int)
a = tuple(input().split())
for i in a:
	dick[i] += 1
if len(dick) == n:
	print(dick[min(dick, key=dick.get)])
else:
	print(0)


(n, m) = map(int, input().split())
list = [int(i) for i in input().split()]
temp = []
for i in range(1, n + 1):
	temp.append(list.count(i))
print(min(temp))


a = input()
b = input()
a = a.split(' ')
b = b.split(' ')
for i in range(len(a)):
	a[i] = int(a[i])
for i in range(len(b)):
	b[i] = int(b[i])
d = 56

def tetris():
	c = []
	for i in range(a[0]):
		c += [0]
	for i in b:
		c[i - 1] += 1
	print(min(c))
tetris()


(n, m) = map(int, input().split())
c = list(map(int, input().split()))
d = [0] * n
for i in range(m):
	for j in range(n):
		if c[i] == j + 1:
			d[j] += 1
print(min(d))


(n, m) = map(int, input().split())
squares = [0] * n
s = [int(i) for i in input().split()]
for i in range(m):
	squares[s[i] - 1] += 1
print(min(squares))


(n, m) = map(int, input().split())
c = list(map(int, input().split()))
hh = [0] * (n + 1)
for i in range(0, len(c)):
	hh[c[i]] += 1
del hh[0]
hmin = m
for i in range(0, n):
	hmin = min(hmin, hh[i])
print(hmin)


import sys
import math
mod = 1000000007

def nospace(l):
	ans = ''.join((str(i) for i in l))
	return ans
(n, m) = map(int, sys.stdin.readline().split(' '))
a = list(map(int, sys.stdin.readline().split(' ')))
li = [0 for i in range(n)]
for aa in a:
	li[aa - 1] += 1
li.sort()
print(li[0])


(n, _) = map(int, input().split())
a = list(map(int, input().split()))
print(min((a.count(x + 1) for x in range(n))))


(columns, squares) = input().split()
columns = int(columns)
squares = int(squares)
columns_with_squares = {}
for i in range(1, columns + 1):
	columns_with_squares[i] = 0
for k in input().split():
	columns_with_squares[int(k)] += 1
print(min(columns_with_squares.values()))


(n, m) = input().split()
k = input().split()
mini = 1001
for i in range(1, int(n) + 1):
	if k.count(str(i)) < mini:
		mini = k.count(str(i))
print(mini)


from collections import Counter
(cols, squares) = [int(x) for x in input().split()]
colsarr = [0] * cols
squarr = Counter([int(x) - 1 for x in input().split()])
if len(squarr) == cols:
	print(min(squarr.values()))
else:
	print(0)


(n, m) = [int(x) for x in input().split(' ')]
a = [int(x) for x in input().split(' ')]
minimum = 999999
for i in range(1, n + 1):
	count = 0
	for j in a:
		if i == j:
			count += 1
	minimum = min(minimum, count)
print(minimum)


(n, m) = input().split()
n = int(n)
m = int(m)
indexes = input().split()
tetris = [indexes.count(str(i)) for i in range(1, n + 1)]
print(min(tetris))


def test_2():
	from collections import Counter
	(n, m) = list(map(int, input().split(' ')))
	a = list(map(int, input().split(' ')))
	a1 = set(a)
	if len(a1) != n:
		print(0)
		return 0
	mincount = min(Counter(a).values())
	print(mincount)
test_2()


from collections import Counter
(n, m) = map(int, input().split())
cols = map(int, input().split())
r = Counter(cols)
r.update(range(1, n + 1))
print(min(r.values()) - 1)


(n, m) = [int(x) for x in input().split()[:2]]
ms = [int(x) for x in input().split()[:m]]
cnt = [0] * n
for i in ms:
	cnt[i - 1] += 1
print(min(cnt))


(x, y) = map(int, input().split())
a = list(map(int, input().split()))
b = [0] * x
for i in a:
	b[i - 1] += 1
print(min(b))


from collections import Counter as c
r = lambda : list(map(int, input().split()))
(n, _) = r()
c = c(r())
print(min((c.get(x + 1, 0) for x in range(n))))


from collections import Counter
(n, m) = map(int, input().split())
c = list(map(int, input().split()))
C = Counter(c)
print((0, min(C.values()))[len(C) == n])


import sys, math, queue, bisect
MOD = 998244353
sys.setrecursionlimit(1000000)
(w, n) = map(int, input().split())
f = {i: 0 for i in range(1, w + 1)}
for ai in map(int, input().split()):
	f[ai] += 1
print(min(f.values()))


(n, m) = [int(i) for i in input().split()]
arr = [0 for i in range(n)]
for i in input().split():
	arr[int(i) - 1] += 1
mi = arr[0]
for i in arr:
	mi = min(i, mi)
print(mi)


inputint = lambda : map(int, input().split())
(n, m) = inputint()
tp = inputint()
arr = [0 for _ in range(n)]
for i in tp:
	arr[i - 1] = arr[i - 1] + 1
print(min(arr))


(m, n) = map(int, input().split())
Arr = [0] * m
L = list(map(int, input().split()))
for i in range(n):
	Arr[L[i] - 1] += 1
print(min(Arr))


info = input().split(' ')
n = int(info[0])
m = int(info[1])
squares = input().split(' ')
grid = [0] * n
for s in squares:
	col = int(s)
	grid[col - 1] += 1
print(min(grid))


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

def calc(squares):
	x = {i + 1: 0 for i in range(n)}
	for i in squares:
		x[i] += 1
	return x
x = calc(squares)
print(min(x.values()))


from functools import reduce
(numberColumns, numberSquares) = map(int, input().split())
totalSquareInColumn = [0 for i in range(numberColumns)]
squareColumnTargets = map(int, input().split())
squareColumnTargets = map(lambda x: x - 1, squareColumnTargets)
for target in squareColumnTargets:
	totalSquareInColumn[target] += 1
deletedColumns = min(totalSquareInColumn)
print(deletedColumns)


(n, m) = map(int, input().split())
c = [0] * n
s = list(map(int, input().split()))
for sq in s:
	c[sq - 1] += 1
print(min(c))


(n, m) = map(int, input().split())
count = [0] * (n + 1)
columns = list(map(int, input().split()))
for c in columns:
	count[c] += 1
min_ = 1000
for i in range(1, n + 1):
	min_ = min(min_, count[i])
print(min_)


I = lambda : map(int, input().split())
(n, m) = I()
li = list(I())
t = [0] * n
for i in li:
	t[i - 1] += 1
print(min(t))


r = lambda : map(int, input().split())
(n, _) = r()
c = list(r())
print(min((c.count(x + 1) for x in range(n))))


def get_ints():
	return [int(n) for n in input().split()]
a = get_ints()
assert len(a) == 2
(n, m) = (a[0], a[1])
c = get_ints()
assert len(c) == m
d = [0 for i in range(n)]
for it in c:
	d[it - 1] += 1
print(min(d))


(n, m) = map(int, input().split())
inp = list(map(int, input().split()))
L = [0] * n
for i in inp:
	L[i - 1] += 1
print(min(L))


from collections import Counter
(n, m) = map(int, input().split())
c = Counter(map(int, input().split()))
print(min((c[i] for i in range(1, n + 1))))


in1 = input().split()
c = input().split()
num = 0
num = c.count('1')
for i in range(1, int(in1[0])):
	num = min(c.count(str(i + 1)), num)
print(num)


def tetris(lst, n):
	a = [0 for i in range(n)]
	for elem in lst:
		a[elem - 1] += 1
	return min(a)
(n, m) = [int(j) for j in input().split()]
b = [int(x) for x in input().split()]
print(tetris(b, n))


def sub(L):
	c = 0
	for x in L:
		L[c] = x - 1
		c += 1
	return L
(n, m) = input().split()
n = int(n)
m = int(m)
c = input().split()
L = [int(x) for x in c]
L_Z = [0] * n
c = 0
if min(L_Z) == 0:
	for x in L:
		L_Z[x - 1] = L.count(x)
while min(L_Z) != 0:
	sub(L_Z)
	c += 1
print(c)


(n, m) = map(int, input().split())
c = map(int, input().split())
cnt = [0] * n
for c_i in c:
	cnt[c_i - 1] += 1
print(min(cnt))


(n, m) = map(int, input().split())
A = [0 for i in range(n)]
B = list(map(int, input().split()))
for b in B:
	A[b - 1] += 1
print(min(A))


(n, m) = map(int, input().split())
x = {}
for i in input().split():
	if x.get(i) is None:
		x[i] = 1
	else:
		x[i] += 1
if len(x.values()) != n:
	print(0)
else:
	print(min(x.values()))


(n, m) = map(int, input().split())
b = []
a = list(map(int, input().split()))
c = []
for i in range(len(a)):
	if a[i] not in c:
		b.append(a.count(a[i]))
		c.append(a[i])
if len(b) == n:
	print(min(b))
else:
	print(0)


(n, m) = map(int, input().split())
A = list(map(int, input().split()))
mf = 10 ** 10
for i in range(1, n + 1):
	mf = min(mf, A.count(i))
print(mf)


a = input().split()
s = input().split()
l = []
m = 0
for i in range(int(a[0])):
	l.append(s.count(str(i + 1)))
print(min(l))


(n, m) = map(int, input().split())
bs = list(map(lambda x: int(x) - 1, input().split()))
cs = list((0 for i in range(n)))
ls = list((0 for i in range(m)))
o = 0
for i in range(m):
	cs[bs[i]] += 1
	ls[cs[bs[i]] - 1] += 1
	if ls[cs[bs[i]] - 1] == n:
		o += 1
print(o)


(n, m) = map(int, input().split())
A = map(int, input().split())
h = {}
for a in A:
	h[a] = h.get(a, 0) + 1
ans = float('inf')
for a in range(1, n + 1):
	ans = min(ans, h.get(a, 0))
print(ans)


import sys
from collections import Counter
(n, m) = map(int, input().split())
cnt = Counter(map(int, input().split()))
ans = 10 ** 9
for i in range(1, n + 1):
	ans = min(ans, cnt[i])
print(ans)


(n, m) = map(int, input().split())
c = input().split()
col = [0] * n
for i in range(len(c)):
	col[int(c[i]) - 1] += 1
print(min(col))


s = input().split()
n = int(s[0])
m = int(s[1])
s = list(map(int, input().split()))
dic = {}
for i in range(n):
	dic.update({i + 1: 0})
for x in s:
	dic[x] += 1
mn = 10 ** 9
for x in dic.keys():
	if dic[x] < mn:
		mn = dic[x]
print(mn)


x = list(map(int, input().split()))
y = list(map(int, input().split()))
z = [0] * x[0]
for i in y:
	z[i - 1] += 1
print(min(z))


(n, m) = (int(x) for x in input().split())
a = [int(x) for x in input().split()]
b = [0] * n
for i in range(m):
	b[a[i] - 1] += 1
print(min(b))


t = 1
while t:
	t -= 1
	(n, m) = map(int, input().split())
	ls = list(map(int, input().split()))
	hash = [0 for _ in range(n)]
	for item in ls:
		hash[item - 1] += 1
	print(min(hash))


(n, m) = input().split()
game = [int(x) for x in input().split()]
field = [0] * int(n)
points = 0
for i in game:
	flag = True
	field[i - 1] += 1
	while flag:
		for x in field:
			if x == 0:
				flag = False
		if flag:
			for j in range(int(n)):
				field[j] -= 1
			points += 1
print(points)


from collections import Counter

def main():
	(n, m) = list(map(int, input().split()))
	c = list(map(int, input().split()))
	print(solve(n, m, c))

def solve(n, m, c):
	cc = Counter(c)
	if len(cc) < n:
		return 0
	return min(cc.values())
main()


(n, m) = map(int, input().split())
c = list(map(int, input().split()))
counts = [0] * n
for val in c:
	counts[val - 1] += 1
print(min(counts))


IN = list(map(int, input().split()))
X = list(map(int, input().split()))
Y = set(X)
if len(Y) < IN[0]:
	print(0)
	exit()
MIN = 10000000
for i in Y:
	if MIN > X.count(i):
		MIN = X.count(i)
print(MIN)


(t1, t2) = map(int, input().split())
a = map(int, input().split())
d = dict()
for i in range(1, t1 + 1):
	d[i] = 0
for el in a:
	d[el] += 1
print(min(d.values()))


from math import ceil, log
(n, m) = list(map(int, input().split()))
b = list(map(int, input().split()))
b.sort()
count = 0
minim = 1001
cur = b[0]
for i in b:
	if i != cur:
		minim = min(count, minim)
		count = 1
		cur = i
	else:
		count += 1
minim = min(count, minim)
if len(set(b)) == n:
	print(minim)
else:
	print(0)


(a, b) = map(int, input().split())
k = list(map(int, input().split()))
f = [0] * a
for i in range(b):
	f[k[i] - 1] = f[k[i] - 1] + 1
x = f[0]
for i in range(a):
	if x > f[i]:
		x = f[i]
print(x)


(n, m) = [int(i) for i in input().split()]
a = [int(i) for i in input().split()]
l = []
for i in range(1, n + 1):
	l.append(a.count(i))
print(min(l))


(n, m) = tuple(input().split())
(n, m) = (int(n), int(m))
c = map(int, input().split())
cols = [0] * n
ans = 0
for c0 in c:
	cols[c0 - 1] += 1
	if all(cols):
		ans += 1
		cols = list(map(lambda x: x - 1, cols))
print(ans)


(a, b) = map(int, input().split())
k = [0] * a
n = list(map(int, input().split()))
for i in n:
	k[i - 1] += 1
ans = 9999999999999999999999999999
for i in k:
	ans = min(i, ans)
print(ans)


from __future__ import division, print_function
import itertools, os, sys, threading
from collections import deque, Counter, OrderedDict, defaultdict

def ii():
	return int(input())

def si():
	return str(input())

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

def li():
	return list(mi())
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 = 1000000007
(dx, dy) = ([-1, 1, 0, 0], [0, 0, 1, -1])

def getKey(item):
	return item[0]

def sort2(l):
	return sorted(l, key=getKey)

def d2(n, m, num):
	return [[num for x in range(m)] for y in range(n)]

def isPowerOfTwo(x):
	return x and (not x & x - 1)

def decimalToBinary(n):
	return bin(n).replace('0b', '')

def ntl(n):
	return [int(i) for i in str(n)]

def powerMod(x, y, p):
	res = 1
	x %= p
	while y > 0:
		if y & 1:
			res = res * x % p
		y = y >> 1
		x = x * x % p1
	return res

def gcd(x, y):
	while y:
		(x, y) = (y, x % y)
	return x
graph = defaultdict(list)
visited = [0] * 1000000
col = [-1] * 1000000

def dfs(v, c):
	if visited[v]:
		if col[v] != c:
			print('-1')
			exit()
		return
	col[v] = c
	visited[v] = 1
	for i in graph[v]:
		dfs(i, c ^ 1)
(n, m) = mi()
l = li()
a = [0] * n
for i in range(m):
	a[l[i] - 1] += 1
print(min(a))


s = input()
blocks = []
r = s.split(sep=' ', maxsplit=1)
for i in range(int(r[0])):
	blocks.append(0)
u = input()
d = u.split(sep=' ', maxsplit=int(r[1]) - 1)
for j in d:
	for s in range(int(r[0])):
		if int(j) == s + 1:
			blocks[s] += 1
print(min(blocks))


import sys

def solve(io):
	N = io.readInt()
	M = io.readInt()
	C = io.readIntArray(M)
	freq = [0] * (N + 1)
	for c in C:
		freq[c] += 1
	io.println(min(freq[1:]))

class IO:
	input = None
	output = None
	raw = ''
	buf = []
	pos = 0

	def __init__(self, inputStream, outputStream):
		self.input = inputStream
		self.output = outputStream

	def readToBuffer(self):
		self.raw = self.input.readline().rstrip('\n')
		self.buf = self.raw.split()
		self.pos = 0

	def readString(self):
		while self.pos == len(self.buf):
			self.readToBuffer()
		ans = self.buf[self.pos]
		self.pos += 1
		return ans

	def readInt(self):
		return int(self.readString())

	def readFloat(self):
		return float(self.readString())

	def readStringArray(self, N, offset=0):
		arr = [None] * offset
		for _ in range(0, N):
			arr.append(self.readString())
		return arr

	def readIntArray(self, N, offset=0):
		arr = [None] * offset
		for _ in range(0, N):
			arr.append(self.readInt())
		return arr

	def readFloatArray(self, N, offset=0):
		arr = [None] * offset
		for _ in range(0, N):
			arr.append(self.readFloat())
		return arr

	def readLine(self):
		while self.pos == len(self.buf):
			self.readToBuffer()
		if self.pos > 0:
			raise ValueError('Cannot call readline in the middle of a line.')
		return self.raw

	def prints(self, s):
		self.output.write(str(s))

	def println(self, s):
		self.prints(s)
		self.prints('\n')

	def flushOutput(self):
		self.output.flush()
pythonIO = IO(sys.stdin, sys.stdout)
solve(pythonIO)
pythonIO.flushOutput()


(n, m) = map(int, input().split())
c = list(map(int, input().split()))
cnt = [c.count(i) for i in range(1, n + 1)]
print(min(cnt))


import math
(n, m) = (int(x) for x in input().split())
c = [int(x) for x in input().split()]
min = 1001
for i in range(n):
	count = c.count(i + 1)
	if count < min:
		min = count
print(min)


(n, m) = map(int, input().split())
l = [0 for i in range(n + 1)]
m = [int(x) for x in input().split()]
for j in m:
	l[j] += 1
print(min(l[1:]))


def main():
	(n, m) = map(int, input().split())
	l = [0] * (n + 1)
	for x in map(int, input().split()):
		l[x] += 1
	print(min(l[1:]))
main()


import itertools

def main():
	(n, m) = [int(v) for v in input().split()]
	d = [int(v) for v in input().split()]
	c = [0 for i in range(n)]
	for v in d:
		c[v - 1] += 1
	print(min(c))
main()


(n, m) = map(int, input().split())
s = list(map(int, input().split()))
ans = m
for i in range(n):
	ans = min(ans, s.count(i + 1))
print(ans)


(n, m) = input().split()
n = int(n)
m = int(m)
indexes = input().split()
index_dict = {str(i): 0 for i in range(1, n + 1)}
for i in indexes:
	index_dict[i] += 1
min_col = min((index_dict[key] for key in index_dict))
print(min_col)


from collections import Counter
(n, m) = list(map(int, input().split()))
ans = [0] * n
for i in list(map(int, input().split())):
	ans[i - 1] = ans[i - 1] + 1
print(min(ans))


(n, m) = map(int, input().split(' '))
cube = list(map(int, input().split(' ')))
CubeCount = [0] * (n + 1)
for i in range(m):
	CubeCount[cube[i]] += 1
Max = max(CubeCount)
CubeCount[0] = Max
Min = min(CubeCount)
print(Min)


(n, m) = map(int, input().split())
s = [0] * n
a = list(map(int, input().split()))
for j in a:
	s[j - 1] += 1
print(min(s))


(n, m) = [int(x) for x in input().split(' ')]
c = [int(x) for x in input().split(' ')]
block_cnt = {}
for block in c:
	if block in block_cnt.keys():
		block_cnt[block] += 1
	else:
		block_cnt[block] = 1
if len(block_cnt) < n:
	ans = 0
else:
	ans = min(block_cnt.values())
print(ans)


def read_data():
	(n, m) = map(int, list(input().strip().split()))
	a = list(map(int, list(input().strip().split())))
	return (n, m, a)

def solve():
	min = 9999999
	cols = [0 for i in range(max(m, n) + 1)]
	for i in range(m):
		cols[a[i]] += 1
	for i in range(1, n + 1):
		if cols[i] < min:
			min = cols[i]
	return min
(n, m, a) = read_data()
print(solve())


(n, m) = [int(x) for x in input().split()]
a = list(map(int, input().split()))
a.sort()
ans = [0] * n
for i in a:
	ans[i - 1] += 1
print(min(ans))


(n, m) = map(int, input().strip().split())
col = [0] * (n + 1)
arr = [int(v) for v in input().strip().split()]
ans = 0

def chk(a):
	for x in a:
		if x == 0:
			return False
	return True
for e in arr:
	col[e] += 1
	if col[e] == 1 and chk(col[1:]):
		ans += 1
		for i in range(1, n + 1):
			col[i] -= 1
print(ans)


t = input().split(' ')
n = int(t[0])
m = int(t[1])
M = [0] * (n + 1)
s = input().split(' ')
for i in s:
	M[int(i)] += 1
sol = M[1]
for j in range(2, len(M)):
	if M[j] < sol:
		sol = M[j]
print(sol)


def num_points(n, c_list):
	num_squares_in_row = {1: 0}
	num_squares_in_col = {}
	curr_row = 1
	points = 0
	for c in c_list:
		if c not in num_squares_in_col:
			num_squares_in_col[c] = 1
			num_squares_in_row[1] += 1
		else:
			num_squares_in_col[c] += 1
			if num_squares_in_col[c] not in num_squares_in_row:
				num_squares_in_row[num_squares_in_col[c]] = 1
			else:
				num_squares_in_row[num_squares_in_col[c]] += 1
		if num_squares_in_row[curr_row] == n:
			points += 1
			curr_row += 1
	return points
[n, m] = [int(x) for x in input().strip().split(' ')]
c_list = [int(x) for x in input().strip().split(' ')]
print(num_points(n, c_list))


from typing import Dict, List, Tuple

def input_lst() -> List[int]:
	return [int(x) for x in input().split()]

def print_out(res: List[int]):
	print(' '.join([str(x) for x in res]))

def get_simple_numbers_less_than(n: int) -> List[int]:
	pr = []
	lp = [0] * (n - 2)
	for i in range(n - 2):
		if lp[i] == 0:
			lp[i] = i
			pr.append(i)
		for p in pr:
			if p > lp[i] or p * i > n:
				break
			lp[p * i] = p
	return pr

def main():
	(n, m) = (int(x) for x in input().split())
	a = input_lst()
	res = [0] * n
	for el in a:
		res[el - 1] += 1
	print(min(res))
main()


(n, m) = map(int, input().split())
v = list(map(int, input().split()))
p = [0] * n
for x in v:
	p[x - 1] += 1
res = min(p)
print(res)


read = lambda : map(int, input().split())
(n, m) = read()
a = [0] * n
for c in read():
	a[c - 1] += 1
print(min(a))


(n, m) = map(int, input().split())
l = [int(x) for x in input().split()]
x = []
for i in range(1, n + 1):
	c = l.count(i)
	x.append(c)
x.sort()
print(x[0])


from collections import Counter
(n, m) = map(int, input().split())
l = list(map(int, input().split()))
c = Counter(l)
if len(c) == n:
	print(min(c.values()))
else:
	print('0')


from collections import defaultdict as dd, deque
(n, m) = list(map(int, input().split()))
H = [0] * n
for c in map(int, input().split()):
	H[c - 1] += 1
print(min(H))


(n, m) = map(int, input().split())
Platform = [0 for i in range(n)]
c = [*map(int, input().split())]
Check = Scor = 0
for i in c:
	if Platform[i - 1] == 0:
		Check += 1
		Platform[i - 1] = 1
	else:
		Platform[i - 1] += 1
	if Check == n:
		for i in range(n):
			Platform[i] -= 1
			if Platform[i] == 0:
				Check -= 1
		Scor += 1
print(Scor)


(n, m) = map(int, input().split())
square = [int(i) for i in input().split()]
ans = 1000000000.0
for i in range(1, n + 1):
	ans = min(ans, square.count(i))
print(ans)


s = input().split()
(n, m) = (int(s[0]), int(s[1]))
dct = {i + 1: 0 for i in range(n)}
s = input().split()
lst = []
for i in s:
	lst.append(int(i))
for i in lst:
	dct[i] += 1
ans = min(dct.values())
print(ans)


(n, m) = map(int, input().split())
s = input().split()
a = dict()
for i in range(m):
	if s[i] in a:
		a[s[i]] += 1
	else:
		a[s[i]] = 1
mn = 1000000000.0
for i in range(1, n + 1):
	val = 0
	if str(i) in a:
		val = a[str(i)]
	mn = min(mn, val)
print(mn)


import sys

class MyReader:

	def __init__(self):
		filename = 'file.in'
		if self.isLocal():
			self.file = open(filename)
		self.str = ['']
		self.ind = 1

	def isLocal(self):
		return len(sys.argv) > 1 and sys.argv[1] == 'SCHULLZ'

	def nextString(self):
		if self.isLocal():
			return self.file.read()
		else:
			return input()

	def nextInt(self):
		return int(self.nextToken())

	def nextToken(self):
		if self.ind >= len(self.str):
			self.ind = 0
			self.str = self.nextString().split()
		self.ind += 1
		return self.str[self.ind - 1]
rdr = MyReader()
n = rdr.nextInt()
m = rdr.nextInt()
a = []
for i in range(0, n):
	a.append(0)
for i in range(0, m):
	k = rdr.nextInt() - 1
	a[k] += 1
res = a[0]
for i in range(1, n):
	res = min(res, a[i])
sys.stdout.write(str(res))
sys.stdout.flush()


args = input().split(' ')
n = int(args[0])
m = int(args[1])
c = input().split(' ')
tc = []
for j in range(0, n + 1):
	tc.append(0)
for i in range(0, m):
	for j in range(0, n + 1):
		if int(c[i]) == j:
			tc[j] = tc[j] + 1
tc.remove(0)
print(min(tc))


from collections import Counter
(n, m) = map(int, input().split())
squares = map(int, input().split())
c = Counter(squares).most_common()
if len(c) < n:
	print(0)
else:
	print(c[-1][1])


(n, m) = map(int, input().split())
l = list(map(int, input().split()))
collumns = {}
for i in range(m):
	if l[i] in collumns:
		collumns[l[i]] += 1
	else:
		collumns[l[i]] = 1
if len(collumns) == n:
	print(min(collumns.values()))
else:
	print(0)


(n, m) = list(map(int, input().split()))
c = list(map(int, input().split()))
d = {}
for i in c:
	if i in d:
		d[i] += 1
	else:
		d[i] = 1
flag = True
for i in range(1, n + 1):
	if i not in d:
		flag = False
if flag:
	print(min(d.values()))
else:
	print(0)


(n, m) = list(map(int, input().split()))
(*c,) = list(map(int, input().split()))
point = 0
amt = []
tmp = set(c)
result = {}
result = {i: 0 for i in range(1, n + 1)}
for i in tmp:
	result[i] = c.count(i)
for i in range(1, n + 1):
	amt.append(result[i])
point = min(amt)
print(point)


n = int(input().split(' ')[0])
li = list(map(int, input().split(' ')))
print(min([li.count(x) for x in range(1, n + 1)]))


(n, m) = list(map(int, input().split()))
lst = []
for x in input().split():
	lst.append(int(x))
array = [0] * n
for x in range(len(lst)):
	array[lst[x] - 1] += 1
print(min(array))


(n, m) = input().split()
s = input()
arr = [0] * int(n)
for num in s.split():
	arr[int(num) - 1] += 1
print(min(arr))


(n, m) = list(map(int, input().split()))
cc = list(map(int, input().split()))
res = 0
board = [0] * n
for c in cc:
	board[c - 1] += 1
	allcols = True
	for b in board:
		allcols = allcols and b > 0
	if allcols:
		board = list(map(lambda x: x - 1, board))
		res += 1
print(res)


(n, m) = map(int, input().strip().split())
col = [0] * (n + 1)
arr = [int(v) for v in input().strip().split()]
ans = 0
for v in arr:
	col[v] += 1
col = col[1:]
print(min(col))


(n, m) = map(int, input().split())
sat = list(map(int, input().split()))
mat = [0] * n
for i in sat:
	mat[i - 1] += 1
print(min(mat))


def divisors(M):
	d = []
	i = 1
	while M >= i ** 2:
		if M % i == 0:
			d.append(i)
			if i ** 2 != M:
				d.append(M // i)
		i = i + 1
	return d

def popcount(x):
	x = x - (x >> 1 & 1431655765)
	x = (x & 858993459) + (x >> 2 & 858993459)
	x = x + (x >> 4) & 252645135
	x = x + (x >> 8)
	x = x + (x >> 16)
	return x & 127

def eratosthenes(n):
	res = [0 for i in range(n + 1)]
	prime = set([])
	for i in range(2, n + 1):
		if not res[i]:
			prime.add(i)
			for j in range(1, n // i + 1):
				res[i * j] = 1
	return prime

def factorization(n):
	res = []
	for p in prime:
		if n % p == 0:
			while n % p == 0:
				n //= p
			res.append(p)
	if n != 1:
		res.append(n)
	return res

def euler_phi(n):
	res = n
	for x in range(2, n + 1):
		if x ** 2 > n:
			break
		if n % x == 0:
			res = res // x * (x - 1)
			while n % x == 0:
				n //= x
	if n != 1:
		res = res // n * (n - 1)
	return res

def ind(b, n):
	res = 0
	while n % b == 0:
		res += 1
		n //= b
	return res

def isPrimeMR(n):
	d = n - 1
	d = d // (d & -d)
	L = [2, 3, 5, 7, 11, 13, 17]
	for a in L:
		t = d
		y = pow(a, t, n)
		if y == 1:
			continue
		while y != n - 1:
			y = y * y % n
			if y == 1 or t == n - 1:
				return 0
			t <<= 1
	return 1

def findFactorRho(n):
	from math import gcd
	m = 1 << n.bit_length() // 8
	for c in range(1, 99):
		f = lambda x: (x * x + c) % n
		(y, r, q, g) = (2, 1, 1, 1)
		while g == 1:
			x = y
			for i in range(r):
				y = f(y)
			k = 0
			while k < r and g == 1:
				ys = y
				for i in range(min(m, r - k)):
					y = f(y)
					q = q * abs(x - y) % n
				g = gcd(q, n)
				k += m
			r <<= 1
		if g == n:
			g = 1
			while g == 1:
				ys = f(ys)
				g = gcd(abs(x - ys), n)
		if g < n:
			if isPrimeMR(g):
				return g
			elif isPrimeMR(n // g):
				return n // g
			return findFactorRho(g)

def primeFactor(n):
	i = 2
	ret = {}
	rhoFlg = 0
	while i * i <= n:
		k = 0
		while n % i == 0:
			n //= i
			k += 1
		if k:
			ret[i] = k
		i += 1 + i % 2
		if i == 101 and n >= 2 ** 20:
			while n > 1:
				if isPrimeMR(n):
					(ret[n], n) = (1, 1)
				else:
					rhoFlg = 1
					j = findFactorRho(n)
					k = 0
					while n % j == 0:
						n //= j
						k += 1
					ret[j] = k
	if n > 1:
		ret[n] = 1
	if rhoFlg:
		ret = {x: ret[x] for x in sorted(ret)}
	return ret

def divisors(n):
	res = [1]
	prime = primeFactor(n)
	for p in prime:
		newres = []
		for d in res:
			for j in range(prime[p] + 1):
				newres.append(d * p ** j)
		res = newres
	res.sort()
	return res

def xorfactorial(num):
	if num == 0:
		return 0
	elif num == 1:
		return 1
	elif num == 2:
		return 3
	elif num == 3:
		return 0
	else:
		x = baseorder(num)
		return 2 ** x * ((num - 2 ** x + 1) % 2) + function(num - 2 ** x)

def xorconv(n, X, Y):
	if n == 0:
		res = [X[0] * Y[0] % mod]
		return res
	x = [X[i] + X[i + 2 ** (n - 1)] for i in range(2 ** (n - 1))]
	y = [Y[i] + Y[i + 2 ** (n - 1)] for i in range(2 ** (n - 1))]
	z = [X[i] - X[i + 2 ** (n - 1)] for i in range(2 ** (n - 1))]
	w = [Y[i] - Y[i + 2 ** (n - 1)] for i in range(2 ** (n - 1))]
	res1 = xorconv(n - 1, x, y)
	res2 = xorconv(n - 1, z, w)
	former = [(res1[i] + res2[i]) * inv for i in range(2 ** (n - 1))]
	latter = [(res1[i] - res2[i]) * inv for i in range(2 ** (n - 1))]
	former = list(map(lambda x: x % mod, former))
	latter = list(map(lambda x: x % mod, latter))
	return former + latter

def merge_sort(A, B):
	(pos_A, pos_B) = (0, 0)
	(n, m) = (len(A), len(B))
	res = []
	while pos_A < n and pos_B < m:
		(a, b) = (A[pos_A], B[pos_B])
		if a < b:
			res.append(a)
			pos_A += 1
		else:
			res.append(b)
			pos_B += 1
	res += A[pos_A:]
	res += B[pos_B:]
	return res

class UnionFindVerSize:

	def __init__(self, N):
		self._parent = [n for n in range(0, N)]
		self._size = [1] * N
		self.group = N

	def find_root(self, x):
		if self._parent[x] == x:
			return x
		self._parent[x] = self.find_root(self._parent[x])
		stack = [x]
		while self._parent[stack[-1]] != stack[-1]:
			stack.append(self._parent[stack[-1]])
		for v in stack:
			self._parent[v] = stack[-1]
		return self._parent[x]

	def unite(self, x, y):
		gx = self.find_root(x)
		gy = self.find_root(y)
		if gx == gy:
			return
		self.group -= 1
		if self._size[gx] < self._size[gy]:
			self._parent[gx] = gy
			self._size[gy] += self._size[gx]
		else:
			self._parent[gy] = gx
			self._size[gx] += self._size[gy]

	def get_size(self, x):
		return self._size[self.find_root(x)]

	def is_same_group(self, x, y):
		return self.find_root(x) == self.find_root(y)

class WeightedUnionFind:

	def __init__(self, N):
		self.parent = [i for i in range(N)]
		self.size = [1 for i in range(N)]
		self.val = [0 for i in range(N)]
		self.flag = True
		self.edge = [[] for i in range(N)]

	def dfs(self, v, pv):
		stack = [(v, pv)]
		new_parent = self.parent[pv]
		while stack:
			(v, pv) = stack.pop()
			self.parent[v] = new_parent
			for (nv, w) in self.edge[v]:
				if nv != pv:
					self.val[nv] = self.val[v] + w
					stack.append((nv, v))

	def unite(self, x, y, w):
		if not self.flag:
			return
		if self.parent[x] == self.parent[y]:
			self.flag = self.val[x] - self.val[y] == w
			return
		if self.size[self.parent[x]] > self.size[self.parent[y]]:
			self.edge[x].append((y, -w))
			self.edge[y].append((x, w))
			self.size[x] += self.size[y]
			self.val[y] = self.val[x] - w
			self.dfs(y, x)
		else:
			self.edge[x].append((y, -w))
			self.edge[y].append((x, w))
			self.size[y] += self.size[x]
			self.val[x] = self.val[y] + w
			self.dfs(x, y)

class Dijkstra:

	class Edge:

		def __init__(self, _to, _cost):
			self.to = _to
			self.cost = _cost

	def __init__(self, V):
		self.G = [[] for i in range(V)]
		self._E = 0
		self._V = V

	@property
	def E(self):
		return self._E

	@property
	def V(self):
		return self._V

	def add_edge(self, _from, _to, _cost):
		self.G[_from].append(self.Edge(_to, _cost))
		self._E += 1

	def shortest_path(self, s):
		import heapq
		que = []
		d = [10 ** 15] * self.V
		d[s] = 0
		heapq.heappush(que, (0, s))
		while len(que) != 0:
			(cost, v) = heapq.heappop(que)
			if d[v] < cost:
				continue
			for i in range(len(self.G[v])):
				e = self.G[v][i]
				if d[e.to] > d[v] + e.cost:
					d[e.to] = d[v] + e.cost
					heapq.heappush(que, (d[e.to], e.to))
		return d

def Z_algorithm(s):
	N = len(s)
	Z_alg = [0] * N
	Z_alg[0] = N
	i = 1
	j = 0
	while i < N:
		while i + j < N and s[j] == s[i + j]:
			j += 1
		Z_alg[i] = j
		if j == 0:
			i += 1
			continue
		k = 1
		while i + k < N and k + Z_alg[k] < j:
			Z_alg[i + k] = Z_alg[k]
			k += 1
		i += k
		j -= k
	return Z_alg

class BIT:

	def __init__(self, n):
		self.BIT = [0] * (n + 1)
		self.num = n

	def query(self, idx):
		res_sum = 0
		while idx > 0:
			res_sum += self.BIT[idx]
			idx -= idx & -idx
		return res_sum

	def update(self, idx, x):
		while idx <= self.num:
			self.BIT[idx] += x
			idx += idx & -idx
		return

class dancinglink:

	def __init__(self, n, debug=False):
		self.n = n
		self.debug = debug
		self._left = [i - 1 for i in range(n)]
		self._right = [i + 1 for i in range(n)]
		self.exist = [True for i in range(n)]

	def pop(self, k):
		if self.debug:
			assert self.exist[k]
		L = self._left[k]
		R = self._right[k]
		if L != -1:
			if R != self.n:
				(self._right[L], self._left[R]) = (R, L)
			else:
				self._right[L] = self.n
		elif R != self.n:
			self._left[R] = -1
		self.exist[k] = False

	def left(self, idx, k=1):
		if self.debug:
			assert self.exist[idx]
		res = idx
		while k:
			res = self._left[res]
			if res == -1:
				break
			k -= 1
		return res

	def right(self, idx, k=1):
		if self.debug:
			assert self.exist[idx]
		res = idx
		while k:
			res = self._right[res]
			if res == self.n:
				break
			k -= 1
		return res

class SparseTable:

	def __init__(self, A, merge_func, ide_ele):
		N = len(A)
		n = N.bit_length()
		self.table = [[ide_ele for i in range(n)] for i in range(N)]
		self.merge_func = merge_func
		for i in range(N):
			self.table[i][0] = A[i]
		for j in range(1, n):
			for i in range(0, N - 2 ** j + 1):
				f = self.table[i][j - 1]
				s = self.table[i + 2 ** (j - 1)][j - 1]
				self.table[i][j] = self.merge_func(f, s)

	def query(self, s, t):
		b = t - s + 1
		m = b.bit_length() - 1
		return self.merge_func(self.table[s][m], self.table[t - 2 ** m + 1][m])

class BinaryTrie:

	class node:

		def __init__(self, val):
			self.left = None
			self.right = None
			self.max = val

	def __init__(self):
		self.root = self.node(-10 ** 15)

	def append(self, key, val):
		pos = self.root
		for i in range(29, -1, -1):
			pos.max = max(pos.max, val)
			if key >> i & 1:
				if pos.right is None:
					pos.right = self.node(val)
					pos = pos.right
				else:
					pos = pos.right
			elif pos.left is None:
				pos.left = self.node(val)
				pos = pos.left
			else:
				pos = pos.left
		pos.max = max(pos.max, val)

	def search(self, M, xor):
		res = -10 ** 15
		pos = self.root
		for i in range(29, -1, -1):
			if pos is None:
				break
			if M >> i & 1:
				if xor >> i & 1:
					if pos.right:
						res = max(res, pos.right.max)
					pos = pos.left
				else:
					if pos.left:
						res = max(res, pos.left.max)
					pos = pos.right
			elif xor >> i & 1:
				pos = pos.right
			else:
				pos = pos.left
		if pos:
			res = max(res, pos.max)
		return res

def solveequation(edge, ans, n, m):
	x = [0] * m
	used = [False] * n
	for v in range(n):
		if used[v]:
			continue
		y = dfs(v)
		if y != 0:
			return False
	return x

	def dfs(v):
		used[v] = True
		r = ans[v]
		for (to, dire, id) in edge[v]:
			if used[to]:
				continue
			y = dfs(to)
			if dire == -1:
				x[id] = y
			else:
				x[id] = -y
			r += y
		return r

class Matrix:
	mod = 10 ** 9 + 7

	def set_mod(m):
		Matrix.mod = m

	def __init__(self, L):
		self.row = len(L)
		self.column = len(L[0])
		self._matrix = L
		for i in range(self.row):
			for j in range(self.column):
				self._matrix[i][j] %= Matrix.mod

	def __getitem__(self, item):
		if type(item) == int:
			raise IndexError('you must specific row and column')
		elif len(item) != 2:
			raise IndexError('you must specific row and column')
		(i, j) = item
		return self._matrix[i][j]

	def __setitem__(self, item, val):
		if type(item) == int:
			raise IndexError('you must specific row and column')
		elif len(item) != 2:
			raise IndexError('you must specific row and column')
		(i, j) = item
		self._matrix[i][j] = val

	def __add__(self, other):
		if (self.row, self.column) != (other.row, other.column):
			raise SizeError('sizes of matrixes are different')
		res = [[0 for j in range(self.column)] for i in range(self.row)]
		for i in range(self.row):
			for j in range(self.column):
				res[i][j] = self._matrix[i][j] + other._matrix[i][j]
				res[i][j] %= Matrix.mod
		return Matrix(res)

	def __sub__(self, other):
		if (self.row, self.column) != (other.row, other.column):
			raise SizeError('sizes of matrixes are different')
		res = [[0 for j in range(self.column)] for i in range(self.row)]
		for i in range(self.row):
			for j in range(self.column):
				res[i][j] = self._matrix[i][j] - other._matrix[i][j]
				res[i][j] %= Matrix.mod
		return Matrix(res)

	def __mul__(self, other):
		if type(other) != int:
			if self.column != other.row:
				raise SizeError('sizes of matrixes are different')
			res = [[0 for j in range(other.column)] for i in range(self.row)]
			for i in range(self.row):
				for j in range(other.column):
					temp = 0
					for k in range(self.column):
						temp += self._matrix[i][k] * other._matrix[k][j]
					res[i][j] = temp % Matrix.mod
			return Matrix(res)
		else:
			n = other
			res = [[n * self._matrix[i][j] % Matrix.mod for j in range(self.column)] for i in range(self.row)]
			return Matrix(res)

	def __pow__(self, m):
		if self.column != self.row:
			raise MatrixPowError('the size of row must be the same as that of column')
		n = self.row
		res = Matrix([[int(i == j) for i in range(n)] for j in range(n)])
		while m:
			if m % 2 == 1:
				res = res * self
			self = self * self
			m //= 2
		return res

	def __str__(self):
		res = []
		for i in range(self.row):
			for j in range(self.column):
				res.append(str(self._matrix[i][j]))
				res.append(' ')
			res.append('\n')
		res = res[:len(res) - 1]
		return ''.join(res)
import sys, random, bisect
from collections import deque, defaultdict
from heapq import heapify, heappop, heappush
from itertools import permutations
from math import log, gcd
input = lambda : sys.stdin.readline().rstrip()
mi = lambda : map(int, input().split())
li = lambda : list(mi())
(n, m) = mi()
a = li()
size = [0 for i in range(n)]
for i in range(m):
	size[a[i] - 1] += 1
print(min(size))


(n, m) = map(int, input().split())
sqrs = list(map(int, list(input().split())))
sums = [0] * n
flags = [False] * n
count = 0
for i in range(m):
	sums[sqrs[i] - 1] += 1
	if flags[sqrs[i] - 1] == False:
		flags[sqrs[i] - 1] = True
	if sum(flags) == n:
		count += 1
		for i in range(n):
			if sums[i] > 0:
				sums[i] -= 1
			if sums[i] == 0:
				flags[i] = False
print(count)


(n, m) = map(int, input().split())
l = [int(x) for x in input().split()]
f = [0] * (n + 1)
for ele in l:
	f[ele] += 1
print(min(f[1:]))


(n, m) = input().strip().split(' ')
(n, m) = [int(n), int(m)]
a = map(int, input().strip().split(' '))
a1 = list(a)
a2 = range(1, n + 1)
w = dict(((x, a1.count(x)) for x in a2))
p = list(w.values())
p.sort()
print(p[0])


(n, k) = map(int, input().split())
L1 = list(map(int, input().split()))
count = 0
L2 = []
for i in range(1, n + 1):
	m = L1.count(i)
	L2.append(m)
print(min(L2))


(n, m) = map(int, input().split(' '))
c = list(map(int, input().split(' ')))
num = [0] * n
for i in range(m):
	num[c[i] - 1] += 1
print(min(num))


import collections
import sys
(n, m) = [int(x) for x in input().split()]
lst = [int(x) for x in input().split()]
lst.sort()
lst1 = []
for i in range(m):
	if lst[i] not in lst1:
		lst1.append(lst[i])
z = collections.Counter(lst)
x = min(z, key=z.get)
if len(lst1) != n:
	print(0)
	sys.exit()
print(z[x])


(c, n) = map(int, input().split())
count = [0] * c
for _ in map(int, input().split()):
	count[_ - 1] += 1
print(min(count))


(n, m) = list(map(int, input().split()))
c = list(map(int, input().split()))
store = [0] * (n + 1)
for i in c:
	store[i] += 1
min = 7585484
for i in store[1:]:
	if min > i:
		min = i
print(min)


(n, m) = map(int, input().split(' '))
l = list(map(int, input().split(' ')))
bonus = 0
cul = [0 for _ in range(n)]
for i in l:
	i = i - 1
	cul[i] = cul[i] + 1
ans = min(cul)
print(ans)


def solve(n, m, c):
	b = [0] * n
	p = 0
	for i in c:
		b[i - 1] += 1
		x = min(b)
		p += x
		for j in range(n):
			b[j] -= x
	return p

def main():
	(n, m) = list(map(int, input().split()))
	c = list(map(int, input().split()))
	print(solve(n, m, c))
main()


R = lambda : map(int, input().split())
(n, m) = R()
a = [0] * n
b = 0
for c in R():
	a[c - 1] += 1
	if all(a):
		b += 1
		for i in range(n):
			a[i] -= 1
print(b)


from collections import defaultdict as dd
d = dd(lambda : 0)
(a, b) = map(int, input().split())
l = list(map(int, input().split()))
ans = b
for i in l:
	d[i] += 1
for i in range(1, a + 1):
	ans = min(ans, d[i])
print(ans)


import sys
import math
(n, m) = map(int, input().split())
a = [0] * n
b = list(map(int, input().split()))
for i in range(m):
	a[b[i] - 1] += 1
print(min(a))


l1 = [int(x) for x in input().split()]
(n, d) = (l1[0], l1[1])
r = [0] * n
l2 = [int(x) for x in input().split()]

def product(l1):
	for x in l1:
		if x == 0:
			return 0
	return 1
points = 0
for x in l2:
	r[x - 1] += 1
	if product(r) != 0:
		r = [y - 1 for y in r]
		points += 1
print(points)


(n, m) = input().strip('\n').split(' ')
n = int(n)
m = int(m)
a = [int(i) for i in input().strip('\n').split(' ')]
ans = 0
column = [0] * n
for i in a:
	column[i - 1] += 1
	f = False
	for j in range(n):
		if column[j] == 0:
			f = True
			break
	if f == False:
		for j in range(n):
			column[j] -= 1
		ans += 1
print(ans)


def main():
	testcase()

def testcase():
	(n, m) = [int(x) for x in input().split()]
	l = [int(x) for x in input().split()]
	print(solve(n, m, l))

def solve(n, m, l):
	counts = [0] * n
	points = 0
	for col in l:
		counts[col - 1] += 1
		for x in counts:
			if x == 0:
				break
		else:
			points += 1
			counts = [x - 1 for x in counts]
	return points
main()


(n, m) = map(int, input().split())
a = list(map(int, input().split()))
b = [0] * (n + 1)
b[0] = 555555
for i in a:
	b[i] += 1
print(str(min(b)))


from sys import stdin, stdout
(n, m) = map(int, input().split())
a = list(map(int, stdin.readline().split()))
b = [0] * (n + 1)
b[0] = 555555
for i in a:
	b[i] += 1
stdout.write(str(min(b)))


(n, m) = map(int, input().split())
c = list(map(int, input().split()))
tmp = c.count(n)
if len(set(c)) != n:
	print(0)
	exit()
for i in set(c):
	if tmp > c.count(i):
		tmp = c.count(i)
print(tmp)


rd = lambda : map(int, input().split())
(n, m) = rd()
a = [0] * n
for x in rd():
	a[x - 1] += 1
print(min(a))


(n, m) = map(int, input().split())
l = list(map(int, input().split()))
d = {}
for i in range(1, n + 1):
	d.update({i: 0})
for i in l:
	try:
		d[i] += 1
	except:
		pass
(x, temp) = (d.keys(), [])
for i in x:
	temp.append(d[i])
print(min(temp))


from collections import deque as de
import math
from collections import Counter as cnt
from functools import reduce
from typing import MutableMapping

def factors(n):
	return set(reduce(list.__add__, ([i, n // i] for i in range(1, int(n ** 0.5) + 1) if n % i == 0)))

class My_stack:

	def __init__(self):
		self.data = []

	def my_push(self, x):
		return self.data.append(x)

	def my_pop(self):
		return self.data.pop()

	def my_peak(self):
		return self.data[-1]

	def my_contains(self, x):
		return self.data.count(x)

	def my_show_all(self):
		return self.data

	def isEmpty(self):
		return len(self.data) == 0
arrStack = My_stack()

def decimalToBinary(n):
	return bin(n).replace('0b', '')

def isPrime(n):
	if n <= 1:
		return False
	if n <= 3:
		return True
	if n % 2 == 0 or n % 3 == 0:
		return False
	i = 5
	while i * i <= n:
		if n % i == 0 or n % (i + 2) == 0:
			return False
		i = i + 6
	return True

def get_prime_factors(number):
	prime_factors = []
	while number % 2 == 0:
		prime_factors.append(2)
		number = number / 2
	for i in range(3, int(math.sqrt(number)) + 1, 2):
		while number % i == 0:
			prime_factors.append(int(i))
			number = number / i
	if number > 2:
		prime_factors.append(int(number))
	return prime_factors

def get_frequency(list):
	dic = {}
	for ele in list:
		if ele in dic:
			dic[ele] += 1
		else:
			dic[ele] = 1
	return dic

def Log2(x):
	return math.log10(x) / math.log10(2)

def isPowerOfTwo(n):
	return math.ceil(Log2(n)) == math.floor(Log2(n))
(n, m) = map(int, input().split())
c = list(map(int, input().split()))
kk = get_frequency(c)
if len(set(c)) == n:
	print(min(kk.values()))
else:
	print(0)


import math
from decimal import Decimal

def na():
	n = int(input())
	b = [int(x) for x in input().split()]
	return (n, b)

def nab():
	n = int(input())
	b = [int(x) for x in input().split()]
	c = [int(x) for x in input().split()]
	return (n, b, c)

def dv():
	(n, m) = map(int, input().split())
	return (n, m)

def dva():
	(n, m) = map(int, input().split())
	a = [int(x) for x in input().split()]
	b = [int(x) for x in input().split()]
	return (n, m, b)

def eratosthenes(n):
	sieve = list(range(n + 1))
	for i in sieve:
		if i > 1:
			for j in range(i + i, len(sieve), i):
				sieve[j] = 0
	return sorted(set(sieve))

def nm():
	n = int(input())
	b = [int(x) for x in input().split()]
	m = int(input())
	c = [int(x) for x in input().split()]
	return (n, b, m, c)

def dvs():
	n = int(input())
	m = int(input())
	return (n, m)
d = {}
(n, m) = map(int, input().split())
a = list(map(int, input().split()))
b = [0] * (n + 1)
for i in a:
	d[i] = d.get(i, 0) + 1
	b[i] = 1
if sum(b) != n:
	print(0)
	exit()
print(min(d.values()))


import sys
import math
import bisect
import itertools

def main():
	(n, m) = map(int, input().split())
	A = [0] * n
	for a in list(map(int, input().split())):
		A[a - 1] += 1
	print(min(A))
main()


(n, m) = map(int, input().split())
A = sorted(list(map(int, input().split())))
k = [0] * n
for i in range(m):
	p = A[i]
	k[p - 1] += 1
s = min(k)
print(s)


(N, M) = map(int, input().split())
X = list(map(int, input().split()))
Q = [0] * N
SCORE = 0
for I in range(M):
	Q[X[I] - 1] += 1
	if Q.count(0) <= 0:
		Q[:] = [E - 1 for E in Q]
		SCORE += 1
print(SCORE)


(n, m) = map(int, input().split())
a = list(map(int, input().strip().split()))
t = [0] * n
for i in a:
	t[i - 1] += 1
minn = min(t)
print(minn)


def main():
	[n_columns, n_squares] = [int(_) for _ in input().split()]
	columns = [0] * n_columns
	squares = [int(_) for _ in input().split()]
	points = 0
	for square in squares:
		columns[square - 1] += 1
		if 0 not in columns:
			points += 1
			for i in range(n_columns):
				columns[i] -= 1
	print(points)
main()


(n, m) = list(map(int, input().split()))
p = list(map(int, input().split()))
print(min((p.count(i) for i in range(1, n + 1))))


(n, m) = map(int, input().split())
d = {x: 0 for x in range(1, n + 1)}
for x in map(int, input().split()):
	d[x] += 1
print(min(d.values()))


(n, m) = [int(x) for x in input().split()]
d = [0] * n
inp = [int(x) - 1 for x in input().split()]
for i in range(m):
	d[inp[i]] += 1
print(min(d))


(n, m) = map(int, input().split())
a = input().split()
for i in range(len(a)):
	a[i] = int(a[i])
b = []
summ = 0
for i in range(n):
	b.append(0)
for i in range(len(a)):
	b[a[i] - 1] += 1
	aaa = 0
	for l in range(len(b)):
		if b[l] == 0:
			aaa = 1
	if aaa == 0:
		summ += 1
		for ii in range(len(b)):
			b[ii] -= 1
print(summ)


(n, m) = map(int, input().split())
mas = [0] * (n + 1)
mas[0] = 10 ** 5
a = list(map(int, input().split()))
for i in a:
	mas[i] += 1
print(min(mas))


L = input().split()
(n, m) = map(int, L)
a = [0] * 1005
L = input().split()
b = list(map(int, L))
for i in range(m):
	a[b[i]] = a[b[i]] + 1
max = 1005
for i in range(n):
	if a[i + 1] < max:
		max = a[i + 1]
print(max)


(n, m) = map(int, input().split())
c = list(map(int, input().split()))
h = [0 for _ in range(n)]
for ci in c:
	h[ci - 1] += 1
print(min(h))


(n, m) = map(int, input().split())
a = list(map(int, input().split()))
cnt = [0] * n
for x in a:
	cnt[x - 1] = cnt[x - 1] + 1
mn = cnt[0]
for x in cnt:
	mn = min(mn, x)
print(mn)


(n, m) = map(int, input().split())
c = list(map(int, input().split()))
s = [0] * n
p = 0
for i in c:
	s[i - 1] += 1
	if 0 not in s:
		p += 1
		for q in range(len(s)):
			if s[q] > 0:
				s[q] -= 1
print(p)


def pro(l):
	b = 1
	for i in l:
		b *= i
	return b

def dele(l):
	for i in range(len(l)):
		l[i] -= 1
(n, m) = map(int, input().split())
l = list(map(int, input().split()))
a = []
for i in range(n):
	a.append(0)
c = 0
for i in l:
	a[i - 1] += 1
	if pro(a) != 0:
		c += 1
		dele(a)
print(c)


def Tetris(n, m, seq):
	cnts = [0] * n
	minCnt = m
	for s in seq:
		cnts[s - 1] += 1
	i = 0
	while i < n:
		if cnts[i] < minCnt:
			minCnt = cnts[i]
		i += 1
	return minCnt
(n, m) = [int(x) for x in input().split()]
seq = [int(x) for x in input().split()]
print(Tetris(n, m, seq))


def getints():
	return map(int, input().split())
(n, m) = getints()
c = list(getints())
mat = [0 for i in range(n)]
ans = 0
for i in range(len(c)):
	col_no = c[i] - 1
	mat[col_no] += 1
	if 0 in mat:
		continue
	for j in range(n):
		mat[j] -= 1
	ans += 1
print(ans)


(n, m) = map(int, input().split())
dic = dict()
for i in range(1, n + 1):
	dic[i] = 0
f = list(map(int, input().split()))
for i in f:
	dic[i] += 1
f = list(dic.values())
print(min(f))


import os
import sys
debug = True
if debug and os.path.exists('input.in'):
	input = open('input.in', 'r').readline
else:
	debug = False
	input = sys.stdin.readline

def inp():
	return int(input())

def inlt():
	return list(map(int, input().split()))

def insr():
	s = input()
	return s[:len(s) - 1]

def invr():
	return map(int, input().split())
test_count = 1
if debug:
	test_count = inp()
for t in range(test_count):
	if debug:
		print('Test Case #', t + 1)
	(n, m) = invr()
	a = inlt()
	h = [0] * (n + 1)
	for x in a:
		h[x] += 1
	print(min(h[1:]))


(n, m) = map(int, input().split())
c = list(map(int, input().split()))
cnt = [0] * n
for x in c:
	cnt[x - 1] += 1
print(min(cnt))


from operator import itemgetter
(n, m) = map(int, input().split())
ci = list(map(int, input().split()))
ai = [0] * (n + 1)
ai[0] = 1001
for i in range(m):
	ai[ci[i]] += 1
print(min(ai))


(cn, num) = map(int, input().split())
cs = input().split()
columns = [0] * cn
for i in range(num):
	c = int(cs[i])
	columns[c - 1] += 1
columns = sorted(columns)
print(columns[0])


(n, m) = map(int, input().split())
arr = list(map(int, input().split()))
screen = [0] * n
for x in arr:
	screen[x - 1] += 1
print(min(screen))


i = lambda : [*map(int, input().split())]
n = i()[0]
a = i()
print(min((a.count(x + 1) for x in range(n))))


(n, m) = map(int, input().split())
cols = [0] * n
x = map(int, input().split())
for i in x:
	cols[i - 1] += 1
print(min(cols))


(n, m) = map(int, input().split(' '))
grid = [0] * n
data = input().split(' ')
for i in range(m):
	grid[int(data[i]) - 1] += 1
index = 0
points = 0
while grid[index] != 0:
	if index == n - 1:
		for i in range(n):
			grid[i] -= 1
		points += 1
		index = -1
	index += 1
print(points)


info = input().split(' ')
n = int(info[0])
m = int(info[1])
points = 0
grid = [0] * n
isFilled = [False] * n
filled_cols = 0
squares = input().split(' ')
for square in squares:
	col = int(square)
	grid[col - 1] += 1
	if not isFilled[col - 1]:
		filled_cols += 1
	isFilled[col - 1] = True
	if filled_cols == n:
		for j in range(n):
			grid[j] -= 1
			if grid[j] == 0:
				isFilled[j] = False
				filled_cols -= 1
		points += 1
print(points)


n = list(map(int, input().split()))
m = n[1]
n = n[0]
A = [0] * n
S = list(map(int, input().split()))
for i in range(m):
	A[S[i] - 1] += 1
ans = min(A)
print(ans)


(n, m) = [int(x) for x in input().split()]
q = [int(x) for x in input().split()]
ans = 1000000000.0
for i in range(1, n + 1):
	s = q.count(i)
	ans = min(ans, s)
print(ans)


I = lambda : map(int, input().split())
(n, _) = I()
C = list(I())
print(min((C.count(c) for c in range(1, n + 1))))


(n, m) = list(map(int, input().split()))
res = [0 for _ in range(n)]
nums = list(map(int, input().split()))
for num in nums:
	res[num - 1] += 1
print('{}'.format(min(res)))


from collections import Counter
(n, m) = map(int, input().split())
a = list(map(int, input().split()))
ac = Counter(a)
ans = 10 ** 9
if len(ac) == n:
	for x in ac.values():
		ans = min(ans, x)
else:
	ans = 0
print(ans)


(q, w) = map(int, input().split())
e = list(map(int, input().split()))
r = list()
for i in range(1, q + 1):
	t = e.count(i)
	r.append(t)
print(min(r))


(n, m) = list(map(int, input().strip().split(' ')))
nums = list(map(int, input().strip().split(' ')))
res = 0
count = [0] * n
for item in nums:
	count[item - 1] += 1
	ok = True
	for i in range(n):
		if count[i] == 0:
			ok = False
			continue
	if ok:
		res += 1
		for i in range(n):
			count[i] -= 1
print(res)


a = [int(q) for q in input().strip().split()]
b = [int(q) for q in input().strip().split()]
c = set(b)
min = 100000
for m in c:
	t = b.count(m)
	if t < min:
		min = t
if len(c) < a[0]:
	print(0)
else:
	print(min)


(n, m) = map(int, input().split())
a = list(map(int, input().split()))
d = {i: 0 for i in range(1, n + 1)}
for i in range(m):
	if a[i] in d:
		d[a[i]] += 1
print(min(d.values()))


import math
(n, m) = map(int, input().split())
l = list(map(int, input().split()))
d = {}
for i in l:
	if i in d:
		d[i] += 1
	else:
		d[i] = 1
k = 1000000
for i in d:
	k = min(k, d[i])
if len(d) != n:
	print('0')
else:
	print(k)


(n, m) = map(int, input().split())
check = [0] * n
ls = list(map(int, input().split()))
result = 0
for i in ls:
	check[i - 1] += 1
	count = 0
	for j in check:
		if j == 0:
			break
		else:
			count += 1
	if count == n:
		result += 1
		for j in range(n):
			check[j] -= 1
print(result)


(n, m) = [int(i) for i in input().split()]
nums = [0] * n
c = [int(i) for i in input().split()]
for i in range(m):
	nums[c[i] - 1] += 1
scores = 0
min = min(nums)
if min != 0:
	scores = min
print(scores)


plat_lenght = int(input().strip().split(' ')[0])
falling_blocks = input().strip().split(' ')
falling_blocks = map(lambda x: int(x) - 1, falling_blocks)
platform = [0] * plat_lenght
for block in falling_blocks:
	platform[block] += 1
print(min(platform))


from collections import Counter
(n, m) = map(int, input().split())
line = list(map(int, input().split()))
if len(set(line)) != n:
	print(0)
else:
	print(Counter(line).most_common()[-1][1])


(n, m) = [int(i) for i in input().split()]
a = [int(i) for i in input().split()]
ar = [0] * n
for i in range(m):
	ar[a[i] - 1] += 1
min = 100000000
for i in range(n):
	if ar[i] < min:
		min = ar[i]
print(min)


(n, m) = [int(x) for x in input().split()]
c = [int(x) for x in input().split()]
total = [0] * n
for x in c:
	total[x - 1] += 1
print(min(total))


(n, m) = map(int, input().split())
c = list(map(int, input().split()))
l = n * [0]
for s in range(m):
	l[c[s] - 1] += 1
print(min(l))


(n, m) = map(int, input().split())
c = [int(x) for x in input().split()]
platform = [0 for _ in range(n)]
for i in range(m):
	platform[c[i] - 1] += 1
print(min(platform))


(n, m) = tuple(map(int, input().split()))
c = list(map(int, input().split()))
l = []
for i in range(n):
	a = int(c.count(i + 1))
	l.append(a)
print(min(l))


(n, m) = [int(i) for i in input().split()]
k = (m + 1) // n
p = m % n
a = [0 for i in range(n)]
s = input().split()
x = 0
for i in range(m):
	f = 1
	a[int(s[i]) - 1] += 1
	for j in range(n):
		if a[j] == 0:
			f = 0
	if f == 1:
		for j in range(n):
			a[j] -= 1
		x += 1
print(x)


(n, m) = map(int, input().split())
list_ = list(map(int, input().split()))
freq = [0] * (n + 1)
for ele in list_:
	freq[ele] += 1
res = m + 1
for i in range(1, n + 1):
	res = min(res, freq[i])
print(res)


(n, m) = map(int, input().split())
A = [0] * n
As = list(map(int, input().split()))
for a in As:
	A[a - 1] += 1
print(min(A))


(x, y) = [int(x) for x in input().split()]
lis = [0] * x
inp = [int(x) for x in input().split()]
for i in inp:
	lis[i - 1] = lis[i - 1] + 1
score = 0
for o in range(int(y / x)):
	j = 0
	for i in lis:
		if i > 0:
			j = j + 1
	if j == x:
		score = score + 1
		for i in range(len(lis)):
			lis[i] = lis[i] - 1
print(score)


def main():
	(n, m) = list(map(int, input().strip().split()))
	l = list(map(int, input().strip().split()))
	for i in list(range(1, n + 1)):
		if i not in l:
			print(0)
			return
	import collections
	counter = collections.Counter(l)
	print(min(counter.values()))
main()


I = lambda : map(int, input().split())
(n, m) = I()
q = {}
for i in range(1, n + 1):
	q[i] = 0
for i in I():
	q[i] += 1
print(min(q.values()))


(n, m) = map(int, input().split())
arr = list(map(int, input().split()))
answer = [0] * n
for i in arr:
	answer[i - 1] += 1
print(min(answer))


def isFull(lst):
	for x in lst:
		if x == 0:
			return False
	return True
inp_1 = input().split()
n = int(inp_1[0])
m = int(inp_1[1])
row = [0] * n
str_lst = input().split()
lst = [int(i) - 1 for i in str_lst]
points = 0
for i in lst:
	row[i] += 1
	if isFull(row):
		points += 1
		row = [i - 1 for i in row]
print(points)


line = input().split()
length = int(line[0])
quantity = int(line[1])
game = [0 for i in range(length)]
entries = input().split()
for column in entries:
	game[int(column) - 1] += 1
minimum = game[0]
for column in range(length):
	if game[int(column) - 1] < minimum:
		minimum = game[int(column) - 1]
print(minimum)


(m, n) = map(int, input().split())
squares = list(map(int, input().split()))
k = 0
f = True
while f:
	for i in range(1, m + 1):
		if squares.count(i) != 0:
			squares.remove(i)
		else:
			f = False
	k += 1
print(k - 1)


(n, _) = [int(x) for x in input().split()]
ch = [int(x) for x in input().split(' ')]
print(min([ch.count(x) for x in range(1, n + 1)]))


from collections import Counter
(a, b) = map(int, input().split())
li = list(map(int, input().split()))
c_ = Counter(li)
if len(c_) == a:
	print(min(c_.values()))
else:
	print('0')


(n, m) = [int(x) for x in input().split()]
a = [int(x) for x in input().split()]
q = [0 for i in range(n)]
r = 1001
for i in range(m):
	q[a[i] - 1] += 1
for i in range(n):
	if r > q[i]:
		r = q[i]
print(r)


(n, m) = list(map(int, input().split(' ')))
seq = list(map(int, input().split(' ')))
countli = [0 for i in range(n)]
for i in seq:
	countli[i - 1] += 1
print(min(countli))


(n, m) = map(int, input().split())
bucket = [0] * n
if n == 1:
	print(m)
else:
	for i in list(map(int, input().split())):
		bucket[i - 1] += 1
	print(min(bucket))


(n, m) = map(int, input().split())
d = {}
a = [int(i) for i in input().split()]
for w in a:
	if w in d.keys():
		d[w] += 1
	else:
		d[w] = 1
sorted(d)
f = True
b = [int(w) for w in d.keys()]
for w in range(1, n + 1):
	if w not in d.keys():
		f = False
if f == True:
	print(min(d.values()))
else:
	print(0)


(n, m) = map(int, input().split())
l = list(map(int, input().split()))
l_set = list(set(l))
if len(l_set) != n:
	print(0)
	exit()
lp = []
for i in l_set:
	lp.append(l.count(i))
print(min(lp))


first_string = input()
first_str_list = list(first_string.split(' '))
n = int(first_str_list[0])
m = int(first_str_list[1])
counter_list = list()
c_list = list()
second_string = input()
second_str_list = list(second_string.split(' '))
for i in range(0, m):
	c_list.append(int(second_str_list[i]))
for i in range(1, n + 1):
	counter_list.append(c_list.count(i))
print(min(counter_list))