The king's birthday dinner was attended by $$$k$$$ guests. The dinner was quite a success: every person has eaten several dishes (though the number of dishes was the same for every person) and every dish was served alongside with a new set of kitchen utensils.All types of utensils in the kingdom are numbered from $$$1$$$ to $$$100$$$. It is known that every set of utensils is the same and consist of different types of utensils, although every particular type may appear in the set at most once. For example, a valid set of utensils can be composed of one fork, one spoon and one knife.After the dinner was over and the guests were dismissed, the king wondered what minimum possible number of utensils could be stolen. Unfortunately, the king has forgotten how many dishes have been served for every guest but he knows the list of all the utensils left after the dinner. Your task is to find the minimum possible number of stolen utensils.

The first line contains two integer numbers $$$n$$$ and $$$k$$$ ($$$1 \le n \le 100, 1 \le k \le 100$$$)  — the number of kitchen utensils remaining after the dinner and the number of guests correspondingly. The next line contains $$$n$$$ integers $$$a_1, a_2, \ldots, a_n$$$ ($$$1 \le a_i \le 100$$$)  — the types of the utensils remaining. Equal values stand for identical utensils while different values stand for different utensils.

Output a single value — the minimum number of utensils that could be stolen by the guests.

NoteIn the first example it is clear that at least one utensil of type $$$3$$$ has been stolen, since there are two guests and only one such utensil. But it is also possible that every person received only one dish and there were only six utensils in total, when every person got a set $$$(1, 2, 3)$$$ of utensils. Therefore, the answer is $$$1$$$.One can show that in the second example at least $$$2$$$ dishes should have been served for every guest, so the number of utensils should be at least $$$24$$$: every set contains $$$4$$$ utensils and every one of the $$$3$$$ guests gets two such sets. Therefore, at least $$$14$$$ objects have been stolen. Please note that utensils of some types (for example, of types $$$2$$$ and $$$4$$$ in this example) may be not present in the set served for dishes.

spisok = [int(number) for number in input().split()]
u, h = spisok[0], spisok[1]
o = [int(o) for o in input().split()]

d = dict()
for c in o:
    d[c] = d.get(c, 0) + 1
MAX = max(d.values())
y = MAX // h
if MAX % h != 0:
    y += 1
print(y * len(d) * h - u)

n, k = map(int, raw_input().split())
l = map(int, raw_input().split())
uniqueList = list(set(l))
uniqueCount = len(uniqueList)
dishes = -1
for i in uniqueList:
	dishes = max(dishes, l.count(i))
if dishes % k == 0:
	p = dishes / k
else:
	p = (dishes/k) + 1
print (k * p * uniqueCount) - n

from math import ceil
n,k=[int(s) for s in input().split()]
mas = [int(s) for s in input().split()]
sett = set(mas)
ans = 0
hm = 0
ans1=0
for x in sett:
    s = mas.count(x)
    if s > ans:
        ans = s
        hm = x

l = ceil(ans/k)
nabor = k*l
for x in sett:
    s = mas.count(x)
    ans1+=nabor-s
print(ans1)

import math

def min_utensil_token( num_utensil, guest, left_utensil):
	max_num_utensil = 0
	utensil_dic = {}
	for utensil in left_utensil:
		if utensil in utensil_dic:
			utensil_dic[utensil] += 1
			if utensil_dic[utensil] > max_num_utensil:
				max_num_utensil = utensil_dic[utensil]
		else:
			utensil_dic[utensil] = 1
			if utensil_dic[utensil] > max_num_utensil:
				max_num_utensil = utensil_dic[utensil]
	#print(math.ceil(max_num_utensil/float(guest)))
	#print(max_num_utensil)
	#Sprint(guest)
	return math.ceil(max_num_utensil/float(guest)) *len(utensil_dic)*int(guest) - int(num_utensil)

n,k = input().split()
utensils = input().split()
print(min_utensil_token(n,k,utensils) )

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

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

u=[]

for j in set(t):
    u.append(t.count(j))

p=0
s=max(u)//k
if max(u)%k>0:
    s+=1

for j in u:
    p+=s*k-j

print(p)

n,k=[int(i)for i in input().split()]
a=[int(i)for i in input().split()]
b=[]
bb=[]#кол-во видов приборов
for i in range(1,101):
	b.append(a.count(i))
	if b[i-1]!=0:
		bb.append(i)
qq=(((max(b)-1)//k)+1)

flag=(k*len(bb)*qq)-n

print(flag)

f_str = input()
s_str = input()
arr_first = f_str.split()
num_of_apps = int(arr_first[0])
num_of_guests = int(arr_first[1])
arr_of_set = []
blyd = 0
count_of_max = 0
all_apps = s_str.split()
for elem in all_apps:
    if all_apps.count(elem) > count_of_max:
        count_of_max = all_apps.count(elem)
    if not elem in arr_of_set:
        arr_of_set.append(elem)
if count_of_max % num_of_guests == 0:
    blyd = count_of_max // num_of_guests
else:
    blyd = (count_of_max) // num_of_guests + 1
pochty_res = blyd * num_of_guests * len(arr_of_set)
res = pochty_res - num_of_apps
print(res)

#!/usr/bin/env python3
import sys

def rint():
    return map(int, sys.stdin.readline().split())
#lines = stdin.readlines()

n , k = rint()

a = list(rint())
adict = dict()
for i in range(n):
    if not a[i] in adict:
        adict[a[i]] =1
    else:
        adict[a[i]] += 1

max_a = max(adict.values())
dish = max_a//k
if max_a % k:
    dish += 1
ans = 0
for i in adict.keys():
    if adict[i] < dish*k:
        ans += dish*k - adict[i]

print(ans)

n,k = map(int,input().split())
a = list(map(int,input().split()))
mn = 0
b = [0]*101
r = 0
for i in range(0,len(a)):
    if   b[a[i]]==0:
        mn+=1
    b[a[i]]+=1

for i in range(0,101):
    r=max((b[i]+k-1)//k,r)

if (k == 1):
    print(mn*(r)*k-n)
else:
    print(mn*(r)*k-n)

from collections import Counter

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

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

# n, k = 5, 2
# a = [1, 2, 2, 1, 3]

# n, k = 10, 3
# a = [1, 3, 3, 1, 3, 5, 5, 5, 5, 100]

kolpr = len(set(a))

di = Counter(a)

maxx = di.most_common()[0][-1]
minn = di.most_common()[-1][-1]

kolbl = (maxx + k - 1)//k

ans = 0

allpr = kolbl*kolpr*k

print(allpr - len(a))

n, k = [int(i) for i in input().split()]
a = [int(i) for i in input().split()]

food = 1
s = dict()
result = 0
arr = []

for i in range(n):
    ans = 0
    if a[i] not in s:
        s[a[i]] = 1
    else:
        ans += s[a[i]] + 1
        s[a[i]] = ans

for key in s:
    if s[key] > k:
        arr.append(s[key])

if len(arr) > 0:
    maxArr = max(arr)
    while maxArr > k:
        food += 1
        maxArr -= k
    for key in s:
        result += (k * food) - s[key]
else:
    for key in s:
        result += k - s[key]

print(result)

import math

n, k = list(map(int, input().split()))
things = list(map(int, input().split())) #приборы
set = []
amountOfEachThing = []
for i in things:
    if i not in set:
        set.append(i)
for j in range(len(set)):
    amountOfEachThing.append(things.count(set[j]))
amountOfPlates = math.ceil(max(amountOfEachThing) / k)
maxAmountOfThings = k * amountOfPlates * len(set)
print(maxAmountOfThings - n)

N, K = map(int, input().split())
cnt = [0]*101
tot = 0
mx = 0
for a in map(int, input().split()):
    cnt[a] += 1
    if cnt[a] == 1: tot += 1
    mx = max(mx, cnt[a])
ndish = (mx + K - 1) // K
print(ndish*K*tot - N)

# coding=utf-8

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

a = [0 for i in range(101)]

for i in [int(i) for i in input().split()]:
    a[i] += 1

mx = 0
s = 0
for i in a:
    mx = max(mx, (i + k - 1) // k)
    if i: s += 1

print(mx * k * s - n)

def error():
    print("Bad input.");exit()

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

test = {1:n not in range(1,101),
        2:k not in range(1,101),
        3:n != len(a),
        4:any([i not in range(1,101) for i in a]),
        }
if any(test.values()):
    error()

kol = 1
ra = {key:a.count(key) for key in set(a)}
if max(ra.values()) > k:
    if max(ra.values()) % k == 0:
        kol += max(ra.values()) // k -1
    else:
        kol += max(ra.values()) // k

print(kol*k*len(set(a)) - n)

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

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

n_of_kind = {}

for i in l:
    n_of_kind[i] = n_of_kind.get(i, 0) + 1

mx_cnt = max(n_of_kind.values())
dish_count = mx_cnt // n + int(mx_cnt%n != 0)

total = dish_count*n*len(n_of_kind)

print(total - sum(n_of_kind.values()))

n, k = map(int, input().split())
a = list(map(int, input().split()))
ans = [0] * 100
for i in range(n):
    ans[a[i] - 1] += 1
c = 0
for i in range(100):
    if ans[i] != 0:
        c += 1
print((max(ans) + k - 1) // k * c * k - n)

import math

def KitchenUtensils():
    n,k = map(int,raw_input().split())
    rem_utensils = list(map(int,raw_input().split()))
    dist_utensils = {}
    for i in rem_utensils:
        if i not in dist_utensils.keys():
            dist_utensils[i] = 1
        else:
            dist_utensils[i] += 1
    max_utensils = max(dist_utensils.values())
    needed = k*math.ceil(float(max_utensils)/k)
    #print needed
    stolen = 0

    for i in dist_utensils:
        if dist_utensils[i] <= needed:
            stolen += needed - dist_utensils[i]

    print int(stolen)

KitchenUtensils()

first = [int(num) for num in input().split()]
sec = input().split()
sec_2 = set(sec)
kol = []
for i in sec_2:
    kol.append(sec.count(i))
if max(kol) > first[1]:
    mn = [(max(kol) // first[1]) + 1, (max(kol) // first[1])][(max(kol) % first[1]) == 0]
    print((len(sec_2)) * mn * first[1] - first[0])
else:
    print(first[1] * len(sec_2) - first[0])

n,k = map(int, input().split(" "))
types = list(map(int, input().split(" ")))
count = [0] * 100
for c in types:
	count[c-1] += 1

maximum = max(count)
if maximum % k != 0:
	maximum += k - (maximum % k)
stolen = 0
for c in count:
	if c != 0:
		stolen += maximum - c
print(stolen)

import sys
from math import floor, ceil

input = sys.stdin.readline

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

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

count = [0 for i in range(101)]
for ut in a:
    count[ut] += 1

maxc = max(count)
while maxc % k != 0:
    maxc += 1

ans = 0
for i in range(1, 101):
    if count[i] != 0:
        ans += maxc - count[i]

print(ans)

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

number = [0] * 101
array = list(map(int, input().split()))
for i in range(n):
    number[array[i]] += 1

q = max(number)
if q % k != 0:
    q = (q - q % k) + k
stolen = 0

for i in number:
    if i != 0:
        stolen += (q - i)

print(stolen)

n, k = map(int, raw_input().split())
a = map(int, raw_input().split())
d = []
for i in xrange(101):
	if a.count(i) != 0:
		d.append(a.count(i))

x = max(d)
y = (x/k)
if x%k != 0: y+=1
sets = y*k*len(d)
print sets - n

n, k = input().split(" ")
pos = input().split(' ')
dishes = 0 #кол-во блюд у каждого гостя
count = 0 #кол-во стол приб. у каждого гостя
count_h = 0
count_help = []
n = int(n)
k = int(k)
for x in pos:
  if x not in count_help:
    count_help += [x]
    count += 1
for y in count_help:
  if pos.count(y) > count_h:
    count_h = pos.count(y)
dishes = (count_h + k - 1) // k
print(count * dishes * k - n)

from collections import Counter
from math import ceil

n,d = input().split()
n = int(n)
d = int(d)

x = list(map(int,input().split(' ')))
tupes = len(set(x))
most_com = Counter(x).most_common()[0][1]
print(ceil(most_com/d)*d*tupes-n)

import math,collections
n,k = map(int,raw_input().strip('\n').split(' '))
a = map(int,raw_input().strip('\n').split(' '))
print int(k*len(list(set(a)))*math.ceil(max(collections.Counter(a).values())*1.0/k)-n)

#RAVENS
#TEAM_2
#ESSI-DAYI_MOHSEN-LORENZO
from collections import Counter
from math import ceil
n,m = map(int,input().split())
arr=list(map(int,input().split()))
yy=ceil((Counter(arr).most_common(1)[0][1])/m)*m
c = Counter(arr)
res = 0
for i in c.keys():
	res+=yy-c[i]
print(res)

def r(x):
    if x > int(x):
        return x+1
    return x

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

sum = 0

co = [0 for _ in range(100)]

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

for i in l:
    co[i-1] += 1

m = max(co)

if m <= k:
    for i in co:
        if i != 0:
            sum += k-i
else:
    k = k*((m//k) + (1 if m/k != m//k else 0))
    for i in co:
        if i != 0:
            sum += k-i

print(sum)

import math

def f(a):
    m = {}
    r = 0
    for ch in a:
        if ch in m:
            m[ch] += 1
        else:
            m[ch] = 1
    u = len(m)
    for k, v in m.items():
        r = max(r, v)
    return r, u

t = [int(x) for x in input().split()]
n = t[0]
k = t[1]
a = [int(x) for x in input().split()]
r, u = f(a)
minimum = math.ceil(r / k)
summ = minimum * u * k
ans = summ - len(a)
print(ans)

import math

n, k = map(int, input().split())
a = list(map(int, input().split()))
mas = [0]*100
count = 0
for i in a:
    if mas[i-1] == 0:
        count += 1
    mas[i - 1] += 1
bluda = math.ceil(max(mas)/k)
print(count*k*bluda - n)

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

ys = [0] * 100
for x in xs:
    ys[x - 1] += 1
m = 0
res = 0
count = 0
for x in ys:
    if x != 0:
        if x > m:
            res += count*(x - m)
            count += 1
            m = x
        elif x == m:
            count += 1
        else:
            res += m - x
            count += 1
if m % k != 0:
    res += (((m // k + 1) * k) - m)* count
print(res)

from collections import Counter
from math import ceil
n,k = map(int, input().split())
a = list(map(int, input().split()))
c = Counter(a).values()
m = int(ceil(max(c)/k)*k)
print(m*len(c)-sum(c))

from math import ceil
n, m = [int(s) for s in input().split()]
a = [int(s) for s in input().split()]
# c, d = np.unique(a), np.unique(a, return_counts=True)[1]
c = []
cnt = 0
for o in a:
    if o not in c:
        c.append(o)
d = []
for i in c:
	d.append(a.count(i))
dishes, set = ceil(max(d) / m), len(c) #���������� ����, ������� � ����� ����
eta = dishes * set * m
print(eta - n)

n, k = map(int, input().split())
a = list(map(int, input().split()))
b = set(a)
m = 0
for i in a:
    m = max(m, a.count(i))
m = (m + k - 1) // k * k
print(m * len(b) - len(a))

n, k = map(int, input().split())
a = list(map(int, input().split()))
b = [0] * 101
for i in a:
  b[i] += 1
c = [(i + k - 1) // k * k for i in b]
mx = max(c)
ans = 0
for i in b:
  if i != 0:
    ans += abs(i - mx)
print(ans)

n, k = [int(a) for a in input().strip().split()]

utensils = [int(x) for x in input().strip().split()]

c = {}
for i in utensils:
    if i in c:
        c[i] += 1
    else:
        c[i] = 1

typecounts = list(c.values())

max = max(typecounts)
set = (-(-max // k))

totalutensils = len(typecounts) * set * k

print(totalutensils - n)

from collections import *
R=lambda:map(int, input().split())
n,k=R()
arr=Counter(R())
print(-max(arr.values())//k*-k*len(arr)-n)

n,k = map(int, raw_input().split())
arr = map(int, raw_input().split())
dic = {}
for it in arr:
	if it in dic:
		dic[it] += 1
	else:
		dic[it] = 1
maxRem = 0
for item in dic:
	if dic[item] > maxRem:
		maxRem = dic[item]
rem = maxRem%k
if rem == 0:
	ideal = maxRem
else:
	ideal = maxRem + (k - rem)
lost = 0
for item in dic:
	lost += ideal - dic[item]
print lost

import math
n , k = map(int,input().split())
arr = list(map(int,input().split()))
ans = 0
x = set(arr)
t = len(x)
cnt = 0

for i in x :
    if arr.count(i) > cnt :
        cnt = arr.count(i)

res = math.ceil(cnt / k )

res2 = res * k * t
stolen = res2 - n
print(stolen)

from math import ceil
n, k = map(int, input().split())
u = map(int, input().split())
x = {}
for i in u:
    if i in x:
        x[i] += 1
    else:
        x[i] = 1
m = -1
for i in x:
    m = max(m, x[i])

total = int(ceil(m/k))*k
s = 0
for i in x:
    s += total - x[i]
print(s)

from collections import Counter
n, k = map(int, input().split())
c = Counter(map(int, input().split()))
most = c.most_common(1)[0][1]
actual = most + (-most % k)
ans = 0
for f in c.values():
	ans += (actual - f)
print(ans)

n, k = list(map(int, input().split()))
a = list(map(int, input().split()))
b = [0] * 100

for i in range(n):
    b[a[i] - 1] += 1

ma = max(b)
if ma % k != 0:
    min_my = (ma // k) * k + k
else:
    min_my = ma

ans = 0

for i in range(100):
    if b[i] != 0:
        ans += min_my - b[i]

print(ans)

R=lambda: list(map(int,input().split()))

n,k=R()
ut=R()

sut=list(set(ut))
ma=0
for i in sut:
         ma=max(ut.count(i),ma)
#print(ma)
print((1+int(ma/k))*k*len(sut)-n if ma%k else ma*len(sut)-n)

import math
guests=input().split()
utensil=input().split()
notstolen=[]
max=0
stolen=0
while utensil!=[]:
    counter=0
    skp=0
    y=utensil[0]
    for i in range (len(utensil)):
        if utensil[0+skp]==y:
            counter+=1
            utensil.pop(0+skp)
        else:
            skp+=1
    notstolen.append(counter)
    if counter>max:
        max=counter
test1=(int(guests[1]))
test2=(math.ceil(max/(int(guests[1]))))
test=test1*test2
#print(test1)
#print(test2)
#print(notstolen)
for i in notstolen:
    stolen+=int(test)-i
print(stolen)

s = input().split()
tree = {}
n = int(s[0])
k = int(s[1])
ma = -1
s = input().split()
for i in range(n):
    if (tree.__contains__(s[i])):
        tree[s[i]] += 1
    else:
        tree[s[i]] = 1
for i in tree.keys():
    ma = max(ma, tree[i])
deesh = 0
if (ma % k == 0):
    deesh = ma // k
else:
    deesh = ma // k + 1
sum = k * len(tree.keys()) * deesh
print(sum - n)

n, k = map(int, input().split())
arr = list(map(int, input().split()))
cnt = [0] * 100
for i in range(n):
    cnt[arr[i] - 1] += 1
ans = 0
b = 1
for i in range(100):
    b = max(b, (cnt[i] + k - 1) // k)
for i in range(100):
    if cnt[i] % (k * b):
        ans += k * b - cnt[i] % (k * b)
print(ans)

from collections import Counter
n, k = map(int, raw_input().split())
a = map(int, raw_input().split())
c = Counter(a).values()
nd = max(c) / k
if max(c) - nd * k:
    nd += 1
print nd * k * len(c) - len(a)

n, k = map(int, input().split())
arr = list(map(int, input().split()))
cnt = dict()
z = 0
mx = 0
for el in arr:
	if el not in cnt:
		cnt[el] = 0
	cnt[el] += 1
for el in cnt:
	mx = max(mx, cnt[el])
mx = (mx - 1) // k + 1
print(mx * len(cnt) * k - n)

from math import ceil
def _mp():
	return map(int,raw_input().split())
n,k = _mp()
a=_mp()
c={}
for i in a:
	if i not in c:
		c[i]=0
	c[i]+=1
ma=-1.0
for i in c:
	ma=max(ma,c[i])
ma=ma*1.0
ct=len(c)
tt=ct*k*int(ceil(ma/k))
for i in range(100):
	if tt-n>=0:
		print tt-n
		break
	else:
		tt=tt+tt

_list = list(map(int, input().split()))
n, k = _list[0], _list[1]

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

numbers = {}

for elem in a:

    try:
        numbers[elem] += 1
    except KeyError:
        numbers[elem] = 1

maxim = max(numbers.values())

if maxim == k:
    pass

elif maxim > k:

    multiplier = 2

    while(maxim > k*multiplier):

        multiplier += 1

    maxim = k*multiplier

elif maxim < k:

    maxim = k

stolen = 0
for elem in numbers.values():
    stolen += maxim - elem

print(stolen)

import math
n, k = map(int,input().split())
a = list(map(int,input().split()))
d = {}
p = sorted(list(set(a)))
temp = 0
for i in p:
    if a.count(i) > temp:
        temp = a.count(i)
print( len(p) * (k +  (k * (math.ceil(   (temp - k) / k)  ) ) ) - len(a)    )

#!/usr/bin/env python
# coding: utf-8

# In[28]:

a = [int(i) for i in input().split()]
b = [int(i) for i in input().split()]
N = a[0]
k = a[1]
b.sort()
n = 1
m = 0
p = 0
r = 0
for i in range(len(b)):
    if b[i] == p:
        n += 1
    if b[i] != p:
        r += 1
        if n > m:
            m = n
        n = 1
    if i == len(b) - 1:
        if n > m:
            m = n
    p = b[i]
if m % k == 0:
    j = m // k
else:
    j = m // k + 1
# m - max одинаковых приборов
# r - кол-во разных приборов
# j - кол-во блюд
print(k*j*r - N)

# In[ ]:

import math
n,k=map(int,input().split())

l=list(map(int,input().split()))
z=set(l)
m=0
for i in z:
   m=max(m,math.ceil(l.count(i)/k))
print(k*m*len(z)-n)

n,k = map(int,input().split())
ai = list(map(int,input().split()))
maxn = [(ai.count(i) // k + int(ai.count(i) % k != 0)) for i in range(101)]
ans = [(max(maxn) * k - ai.count(i))*int(ai.count(i)>0) for i in range(101)]
print(sum(ans))

import math
n,k = [int(i) for i in input().split()]
l = [int(i) for i in input().split()]
d = dict()
for i in l:
	if i in d:
		d[i]+=1
	else:
		d[i]=1;
ll = []
for i in d:
	ll.append(d[i])

x= max(ll)
for i in range(math.ceil(x/k)*k):
	for  i in d:
		d[i]-=1
s=0
for i in d:
	s+=d[i]

print(-s)

n,k=map(int,input().split())
pr=input().split()
s=0
pr1=set(pr)
pr1=list(pr1)
bl=None
for i in range(len(pr1)):
    if pr.count(pr1[i])>s:
        s=pr.count(pr1[i])
if s>k:
    while s%k!=0:
        s+=1
    bl=s//k
elif s<=k:
    bl=1
prib=len(pr1)
print(bl*prib*k-n)

# coding: utf-8
import math

n, k = map(int, input().split())  # N utensils remaining and  K guests

utensils = list(map(int, input().split()))  # list of utensils remaining
common = set()
types = 0
maior = 0

for x in utensils:
    common.add(x)

types = len(common)

quant = dict((el, 0) for el in common)

for v in utensils:
    quant[v] += 1

for o, p in quant.items():
    if p >= maior:
        maior = p

minimum = math.ceil(maior / k)

result = (types * minimum * k) - n
#print(k, types, minimum)
print(result)

from math import ceil
n , k = map(int,input().split())
a = [int(_) for _ in input().split()]
b = set(a)
w = 0
for i in b:
    w = max(a.count(i),w)
print((k*ceil(w/k)*len(b))-n)

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

d = {}

for i in range(1, 101):
    d[i] = 0

s = 0

for i in range(n):
    d[l[i]] += 1
    s = s + 1

pr = 0

for i in d:
    if d[i] != 0:
        pr += 1

smax = 0

for i in d:
    if d[i] > smax:
        smax = d[i]

if smax % m == 0:
    bl = smax // m
else:
    bl = smax // m + 1

print(max(bl*m*pr - s,0))

import math
from collections import Counter

in1 = lambda: int(input())
inm = lambda: map(int, input().split())
inl = lambda: list(map(int, input().split()))

n, k = inm()
arr = inl()
cnt_arr = Counter(arr)

different_utensils = len(cnt_arr)
biggest_num = max(cnt_arr.values())
dishes = math.ceil(biggest_num / k)
all_utensils = dishes * k * different_utensils

stolen = all_utensils - n
print(stolen)

#!/usr/bin/env python
"""
This file is part of https://github.com/Cheran-Senthil/PyRival.

Copyright 2018 Cheran Senthilkumar all rights reserved,
Cheran Senthilkumar <hello@cheran.io>
Permission to use, modify, and distribute this software is given under the
terms of the MIT License.

"""
from __future__ import division, print_function

import cmath
import itertools
import math
import operator as op
# import random
import sys
from atexit import register
from bisect import bisect_left, bisect_right
from collections import Counter
# from copy import deepcopy
# from decimal import Decimal
# from difflib import SequenceMatcher
# from fractions import Fraction
# from heapq import heappop, heappush

if sys.version_info[0] < 3:
    # from cPickle import dumps
    from io import BytesIO as stream
    # from Queue import PriorityQueue, Queue
else:
    # from functools import reduce
    from io import StringIO as stream
    from math import gcd
    # from pickle import dumps
    # from queue import PriorityQueue, Queue

if sys.version_info[0] < 3:
    class dict(dict):
        """dict() -> new empty dictionary"""
        def items(self):
            """D.items() -> a set-like object providing a view on D's items"""
            return dict.iteritems(self)

        def keys(self):
            """D.keys() -> a set-like object providing a view on D's keys"""
            return dict.iterkeys(self)

        def values(self):
            """D.values() -> an object providing a view on D's values"""
            return dict.itervalues(self)

    def gcd(x, y):
        """gcd(x, y) -> int
        greatest common divisor of x and y
        """
        while y:
            x, y = y, x % y
        return x

    input = raw_input
    range = xrange

    filter = itertools.ifilter
    map = itertools.imap
    zip = itertools.izip

def sync_with_stdio(sync=True):
    """Set whether the standard Python streams are allowed to buffer their I/O.

    Args:
        sync (bool, optional): The new synchronization setting.

    """
    global input, flush

    if sync:
        flush = sys.stdout.flush
    else:
        sys.stdin = stream(sys.stdin.read())
        input = lambda: sys.stdin.readline().rstrip('\r\n')

        sys.stdout = stream()
        register(lambda: sys.__stdout__.write(sys.stdout.getvalue()))

def main():
    n, k = map(int, input().split(' '))
    a = Counter(map(int, input().split(' ')))
    m = max(a.values())

    print((k * int(math.ceil(m / k))) * len(a) - sum(a.values()))

if __name__ == '__main__':
    sync_with_stdio(False)

    if 'PyPy' in sys.version:
        from _continuation import continulet

        def bootstrap(c):
            callable, arg = c.switch()
            while True:
                to = continulet(lambda _, f, x: f(x), callable, arg)
                callable, arg = c.switch(to=to)

        c = continulet(bootstrap)
        c.switch()

        main()

    else:
        import threading

        sys.setrecursionlimit(2097152)
        threading.stack_size(134217728)

        main_thread = threading.Thread(target=main)
        main_thread.start()
        main_thread.join()

from math import *

n, k = map(int, input().split())
pribory = list(map(int, input().split()))
_type = []
_val = []

for i in pribory:
    if i in _type:
        _val[_type.index(i)] += 1
    else:
        _type.append(i)
        _val.append(1)

nabor = 1
for i in range(len(_val)):
    if _val[i] > k and ceil(_val[i]/k) > nabor:
        nabor = ceil(_val[i]/k)
_max = 0
# print(_type)
# print(_val)
# print(nabor)
for i in _val:
    if i < k * nabor:
        _max += k*nabor - i
print(_max)

import math
n, k = map(int, input().split())
a = list(map(int, input().split()))
d = max([a.count(q) for q in a])
f = len(set(a))
g = math.ceil(d/k)
print(f*g*k-n)

from collections import Counter
n,k=map(int,input().strip().split())
arr=list(map(int,input().strip().split()))
dct=Counter(arr)

values = list(dct.values())
keys=list(dct.keys())
maxi=max(values)
maxis=0
if maxi%k==0:
    maxis=maxi//k
else:
    maxis=(maxi//k)+1

total=len(keys)*maxis*k
print(total-n)

n, k = [int(x) for x in input().split()]
T = [int(x) for x in input().split()]
D = {}
for i in T:
    if i in D:
        D[i] += 1
    else:
        D[i] = 1

S = list(D.values())
L = []
for j in S:
    L.append(((j-1)//k)+1)
total = 0
for i in L:
    total += i*k

print(max(L)*k*len(S)-n)

n,k = map(int,input().split(" "))
arr = list(map(int,input().split(" ")))
s = set(arr)
l = len(s)
m = 0
for i in arr:
	count = arr.count(i)
	if(count>m):
		m = count
dishes = (m+k-1)//k
print(dishes*l*k-n)

import math
n, k = map(int, input().split())
prb = []
for i in range(101):
    prb.append(0)
prib = list(map(int,input().split()))
for i in range(len(prib)):
    prb[prib[i]] += 1
res = 0
blud = 1
if max(prb) > k:
    blud = max(prb) / k
    blud = math.ceil(blud)
for i in range(len(prb)):
    if prb[i] == 0:
        continue
    else:
        res += blud * k - prb[i]
print(res)

t = list(map(int, input().split(" ")))
n = t[0]
k = t[1]
a = list(map(int, input().split(" ")))
t = set(a)
t = list(t)
m = 1
for i in range(len(t)):
	if a.count(t[i])>k:
		temp = a.count(t[i])//k
		if temp*k!=a.count(t[i]):
		    temp = temp + 1
		if temp>m:
			m = temp
print(m*k*len(t)-n)

def r(x):
    if x > int(x):
        return x+1
    return x

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

sum = 0

co = [0 for _ in range(100)]

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

for i in l:
    co[i-1] += 1

m = max(co)

if m <= k:
    for i in co:
        if i != 0:
            sum += k-i
else:
    k = k*((m//k) + (1 if m/k != m//k else 0))
    for i in co:
        if i != 0:
            sum += k-i

print(sum)

import math

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

dic  = {}
for el in a:
    try:
        dic[el] += 1
    except:
        dic[el] = 1

ma = max(dic.values())
piatti = math.ceil(ma / k)
kit = len(dic)

print(piatti * kit * k - n)

import math

inp = input().split()
n = int(inp[0])
k = int(inp[1])
left = input().split()
types = {}
maxx = 0
for i in range(n):
    if i == 0:
        maxx = left[0]
    try:
        types[left[i]] += 1
    except Exception:
        types[left[i]] = 1
    if types[left[i]] >= types[str(maxx)]:
        maxx = left[i]

needed = 0
dishes = 0
if types[str(maxx)] % k == 0:
    dishes = types[str(maxx)] / k
else:
    dishes = math.ceil((types[str(maxx)] + 0.1)/k)
for a in types:
    if dishes*k > types[a]:
        needed += dishes*k - types[a]
print(int(needed))

import sys
import math

lines = []
for line in sys.stdin:
	lines.append(line.rstrip('\n'))

n,k = [int(x) for x in lines.pop(0).split(" ")]

remainingUtensils = [int(x) for x in lines.pop(0).split(" ")]

n = len(remainingUtensils)

numberOfRemainingUtensilsByUtensilType = {}
for remainingUtensil in remainingUtensils:
    if not remainingUtensil in numberOfRemainingUtensilsByUtensilType:
        numberOfRemainingUtensilsByUtensilType[remainingUtensil] = 0
    numberOfRemainingUtensilsByUtensilType[remainingUtensil] += 1

maximumNumberOfRemaningUtentils = max([value for key,value in numberOfRemainingUtensilsByUtensilType.items()])

numberOfDishes = math.ceil(maximumNumberOfRemaningUtentils / k)

print(numberOfDishes * k * len(set(remainingUtensils)) - n)

#import sys
import math
import bisect
import collections
import itertools
#from sys import stdin,stdout
from math import gcd,floor,sqrt,log
from collections import defaultdict as dd, Counter as ctr
from bisect import bisect_left as bl, bisect_right as br
from itertools import permutations as pr, combinations as cb

#sys.setrecursionlimit(100000000)

#$#$#$#$#$#$#$#$#$#$#$#$#$#$#$#$#$#$#$#$#$#$#$#$#$#$#$#$#$#$#$

inp    = lambda: int(input())
strng  = lambda: input().strip()
jn     = lambda  x,l: x.join(map(str,l))
strl   = lambda: list(input().strip())
mul    = lambda: map(int,input().strip().split())
mulf   = lambda: map(float,input().strip().split())
seq    = lambda: list(map(int,input().strip().split()))

#$#$#$#$#$#$#$#$#$#$#$#$#$#$#$#$#$#$#$#$#$#$#$#$#$#$#$#$#$#$#$
# p_inf = float('inf')
# n_inf = float('-inf')
#To find mex
# def mex(arr):
#     nList = set(arr)
#     mex = 0
#     while mex in nList:
#         mex += 1
#     return(mex)

def results(arr, k):
    tmp = ctr(arr)
    q = max(tmp.values())
    p = q // k
    if(q % k):
        p += 1
    p = p * k * len(tmp)
    return p

def main():
    nk = seq()
    a = seq()
    n, k = nk[0], nk[1]
    print(results(a, k) - n)
if __name__ == '__main__':
    main()

n,k=map(int,input().split())
a=input().split()
D={}
for i in a:
    if i in D:
        D[i]+=1
    else:
        D[i]=1
gostu_max=max(D.values())
if gostu_max%k==0:
    bluda=gostu_max//k
else:
    bluda=(gostu_max//k)+1
b=bluda*k*len(D)
print(b-n)

n,k=[int(x) for x in input().split()]
a=[int(x) for x in input().split()]
mp={}
for i in a:
    mp[i]=a.count(i)
diff=len(list(mp.keys()))
m=max(list(mp.values()))
# print(diff,m)
if m%k==0:
    m=m//k
else:
    m=m//k+1
# print(m,diff)
missing=m*diff*k-n
# print(f"diff is {diff} max is {m} missing is {missing}")
print(missing)

def solution(n, k, cutlary):
    cset = set(cutlary)
    cutmax = dict()
    for c in cutlary:
        cutmax[c] = cutmax.get(c, 0) + 1
    plates = max(map(lambda x: (x // k) if x % k == 0 else ((x // k) + 1), cutmax.values()))
    return plates*len(cset)*k - n

if __name__ == '__main__':
    n, k = tuple(map(int, input().split()))
    cutlary  = list(map(int, input().split()))
    print(solution(n, k , cutlary))

import math
n,k=map(int,input().split())
a=list(map(int,input().split()))
b=set(a)
kolb=0
for i in b:
    z=a.count(i)
    if z>kolb: kolb=z
print(math.ceil(kolb/k)*len(b)*k-n)

n,k=map(int,input().split())
a=list(map(int,input().split()))
ma=0
for i in set(a):
    ma=max(ma,a.count(i))
r=-((-ma)//k)*k
ans=0
for i in set(a):
    ans+=(r-a.count(i))
print(ans)

import math

class CodeforcesTask1032ASolution:
    def __init__(self):
        self.result = ''
        self.n_k = []
        self.utens = []

    def read_input(self):
        self.n_k = [int(x) for x in input().split(" ")]
        self.utens = [int(x) for x in input().split(" ")]

    def process_task(self):
        cnts = [self.utens.count(x) for x in list(set(self.utens))]
        all = len(set(self.utens)) * math.ceil(max(cnts) / self.n_k[1]) * self.n_k[1]
        missing = all - sum(cnts)
        self.result = str(missing)

    def get_result(self):
        return self.result

if __name__ == "__main__":
    Solution = CodeforcesTask1032ASolution()
    Solution.read_input()
    Solution.process_task()
    print(Solution.get_result())

n, k = [int(x) for x in input().split()]
T = [int(x) for x in input().split()]
D = {}
for i in T:
    if i in D:
        D[i] += 1
    else:
        D[i] = 1

S = list(D.values())
L = []
for j in S:
    L.append(((j-1)//k)+1)
total = 0
for i in L:
    total += i*k

print(max(L)*k*len(S)-n)

n,k = map(int, input().split())
L = list(map(int, input().split()))
f = [0]*101
for i in L:
    f[i] += 1
ma = 0
for i in f:
    ma = max(ma,(i+k-1)//k)
p = len(set(L))
print((ma*p*k)-n)

num = [0] * 105
n,k = map(int,input().split())
a = list(map(int,input().split()))
mx = 0
for i in range(n):
    num[a[i]]+=1
    mx = max(mx,a[i])
cnt = 0
for i in range(1,mx+1):
    if num[i] != 0:
        cnt = max(cnt,num[i])
if cnt % k != 0:
    cnt = (cnt // k + 1) * k
ans = 0
for i in range(1,mx+1):
    if num[i] != 0:
        ans += cnt - num[i]
print(ans)

n, k = [int(i) for i in input().split()]
data = {}
for i in input().split():
    if i in data:
        data[i] += 1
    else:
        data[i] = 1

max_num = 0
for i in data:
    if data[i] > max_num:
        max_num = data[i]
all_dishes = 0
if max_num % k == 0:
    all_dishes = max_num // k
else:
    all_dishes = max_num // k + 1
dishes = 0
for i in data:
    dishes += data[i]
print(all_dishes * k * len(data) - dishes)

''' CODED WITH LOVE BY SATYAM KUMAR '''

from sys import stdin, stdout
import cProfile, math
from collections import Counter
from bisect import bisect_left,bisect,bisect_right
import itertools
from copy import deepcopy
from fractions import Fraction
import sys, threading
sys.setrecursionlimit(10**6) # max depth of recursion
threading.stack_size(2**27)  # new thread will get stack of such size

printHeap = str()
memory_constrained = False
P = 10**9+7
import sys
sys.setrecursionlimit(10000000)

class Operation:
    def __init__(self, name, function, function_on_equal, neutral_value=0):
        self.name = name
        self.f = function
        self.f_on_equal = function_on_equal
def add_multiple(x, count):
    return x * count
def min_multiple(x, count):
    return x
def max_multiple(x, count):
    return x
sum_operation = Operation("sum", sum, add_multiple, 0)
min_operation = Operation("min", min, min_multiple, 1e9)
max_operation = Operation("max", max, max_multiple, -1e9)
class SegmentTree:
    def __init__(self,
                 array,
                 operations=[sum_operation, min_operation, max_operation]):
        self.array = array
        if type(operations) != list:
            raise TypeError("operations must be a list")
        self.operations = {}
        for op in operations:
            self.operations[op.name] = op
        self.root = SegmentTreeNode(0, len(array) - 1, self)
    def query(self, start, end, operation_name):
        if self.operations.get(operation_name) == None:
            raise Exception("This operation is not available")
        return self.root._query(start, end, self.operations[operation_name])
    def summary(self):
        return self.root.values
    def update(self, position, value):
        self.root._update(position, value)
    def update_range(self, start, end, value):
        self.root._update_range(start, end, value)
    def __repr__(self):
        return self.root.__repr__()
class SegmentTreeNode:
    def __init__(self, start, end, segment_tree):
        self.range = (start, end)
        self.parent_tree = segment_tree
        self.range_value = None
        self.values = {}
        self.left = None
        self.right = None
        if start == end:
            self._sync()
            return
        self.left = SegmentTreeNode(start, start + (end - start) // 2,
                                    segment_tree)
        self.right = SegmentTreeNode(start + (end - start) // 2 + 1, end,
                                     segment_tree)
        self._sync()
    def _query(self, start, end, operation):
        if end < self.range[0] or start > self.range[1]:
            return None
        if start <= self.range[0] and self.range[1] <= end:
            return self.values[operation.name]
        self._push()
        left_res = self.left._query(start, end,
                                    operation) if self.left else None
        right_res = self.right._query(start, end,
                                      operation) if self.right else None
        if left_res is None:
            return right_res
        if right_res is None:
            return left_res
        return operation.f([left_res, right_res])
    def _update(self, position, value):
        if position < self.range[0] or position > self.range[1]:
            return
        if position == self.range[0] and self.range[1] == position:
            self.parent_tree.array[position] = value
            self._sync()
            return
        self._push()
        self.left._update(position, value)
        self.right._update(position, value)
        self._sync()
    def _update_range(self, start, end, value):
        if end < self.range[0] or start > self.range[1]:
            return
        if start <= self.range[0] and self.range[1] <= end:
            self.range_value = value
            self._sync()
            return
        self._push()
        self.left._update_range(start, end, value)
        self.right._update_range(start, end, value)
        self._sync()
    def _sync(self):
        if self.range[0] == self.range[1]:
            for op in self.parent_tree.operations.values():
                current_value = self.parent_tree.array[self.range[0]]
                if self.range_value is not None:
                    current_value = self.range_value
                self.values[op.name] = op.f([current_value])
        else:
            for op in self.parent_tree.operations.values():
                result = op.f(
                    [self.left.values[op.name], self.right.values[op.name]])
                if self.range_value is not None:
                    bound_length = self.range[1] - self.range[0] + 1
                    result = op.f_on_equal(self.range_value, bound_length)
                self.values[op.name] = result
    def _push(self):
        if self.range_value is None:
            return
        if self.left:
            self.left.range_value = self.range_value
            self.right.range_value = self.range_value
            self.left._sync()
            self.right._sync()
            self.range_value = None
    def __repr__(self):
        ans = "({}, {}): {}\n".format(self.range[0], self.range[1],
                                      self.values)
        if self.left:
            ans += self.left.__repr__()
        if self.right:
            ans += self.right.__repr__()
        return ans

def display(string_to_print):
    stdout.write(str(string_to_print) + "\n")

def primeFactors(n): #n**0.5 complex
    factors = dict()
    for i in range(2,math.ceil(math.sqrt(n))+1):
        while n % i== 0:
            if i in factors:
                factors[i]+=1
            else: factors[i]=1
            n = n // i
    if n>2:
        factors[n]=1
    return (factors)

def isprime(n):
    """Returns True if n is prime."""
    if n < 4:
        return True
    if n % 2 == 0:
        return False
    if n % 3 == 0:
        return False
    i = 5
    w = 2
    while i * i <= n:
        if n % i == 0:
            return False
        i += w
        w = 6 - w
    return True

def test_print(*args):
    if testingMode:
        print(args)

def display_list(list1, sep=" "):
    stdout.write(sep.join(map(str, list1)) + "\n")

def get_int():
    return int(stdin.readline().strip())

def get_tuple():
    return map(int, stdin.readline().split())

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

memory = dict()
def clear_cache():
    global memory
    memory = dict()
def cached_fn(fn, *args):
    global memory
    if args in memory:
        return memory[args]
    else:
        result = fn(*args)
        memory[args] = result
        return result

# -------------------------------------------------------------- MAIN PROGRAM
TestCases = False
testingMode = False
optimiseForReccursion = False #Can not be used clubbed with TestCases

def main():
    n, k = get_tuple()
    li = get_list()
    count = Counter(li)
    l = math.ceil(max(count.values())/k)
    print(l*k*len(count.keys())-len(li))

# --------------------------------------------------------------------- END

if TestCases:
    for _ in range(get_int()):
        cProfile.run('main()') if testingMode else main()
else: (cProfile.run('main()') if testingMode else main()) if not optimiseForReccursion else threading.Thread(target=main).start()

utensils=[]
index,sum,N=0,0,2
n,k=input().split()
n=int(n)
k=int(k)
utensils=input().split()
utensils=[int(i) for i in utensils]
utensils.sort()
while index < len(utensils):
    num=utensils.count(utensils[index])
    index=utensils.count(utensils[index])+index
    sum=k-num+sum
    if (k-num)<0:
        k=k*N/(N-1)
        N=N+1
        index=0
        sum=0
        continue
    sum=int(sum)
print(sum)

from collections import Counter
import math
n, k = input().strip().split(' ')
n, k=  [int(n), int(k)]

a = list(map(int, input().split()))
most_common,num_most_common = Counter(a).most_common(1)[0]
dishes = math.ceil(num_most_common/k)
print((len(set(a))*k*dishes)-n)

n,K=map(int,input().split())
A=list(map(int,input().split()))

from collections import Counter
counter=Counter(A)
L=len(counter)
U=-(-max(counter.values())//K)

print(L*U*K-n)

import gzip, base64

exec(gzip.decompress(base64.b64decode(
    b'H4sIAK2/8VsC/0VWx7KrShLc36+Y3X0viHkYYRezQI'
    b'BwEk7'
    b'4Hd57z9fPmYiBq1VTndWUqisz+fUr2ZPor+ws+n/iJOqafkym6'
    b'a8wmBIc/SfE0f8F4+SvX//6+YW/BXQSaRkB'
    b'SXtiQBh2dkIev893/MAB7+FCayHUv/8P'
    b'Ra8FJ86JJzochXjClmVVKz83l6IeYt7h3pz'
    b'TF641d99yvskpH+t4BR+nIhCgvCYj6GtNGYC9pnU4CDXmR04k'
    b'7ZsLIE1oJEzF4JWS9gTkHCHP4'
    b'3NGqi4hkHSaGBn2ugB3'
    b'hTwljy5L+jHVnDwFX/GyxY/uepibSMnXbnacz/nk/KJq6Q'
    b'zHnaUvF'
    b'VCj8kplxw/MLc9yooRRv7J8uOgDwwa'
    b'sBJXF16kSJVxhcKLRL/dZbO6'
    b'kNi3oXGCjQb+q'
    b'sEQM54qEWrdjDEn6/GknOz5fHE69W7'
    b'+tj80cvuPJ3V2tQy4AucEft'
    b'yw5'
    b'bPag9jeRyK23KZoFFLUPIr'
    b'x011'
    b'P6WukTsWxQcg9jL+AbsNcWG6jyV/Rr5oWeis1V4'
    b'WiFLxXDOtpilXZUbJxoAd28qxVx3oIAHiJoGguvIMY6y'
    b'I'
    b'4osZi6EhvKdoTVVoisaTBoAcM5xSq5'
    b'WZw1wbyk/uBJ+n3ppxSR1'
    b'9plxSMk+IUz7VP/GJkzOPqrpJ7EXGTCjQqlkooA8Hy901i4gv'
    b'VSDwtyPTm8MQvbXrMrJj'
    b'iJ9z2VJMtnuDeImOJ8'
    b'VvN/NpwezD9YiTgdf'
    b'6XF1Ju1YwDI6umeBTAnF8VZT8jZuXKDPSajNgU6iDP'
    b'aqA'
    b'hrIkN72vYFtlj70IXnZ0Cer6LT6GJ6fWcc'
    b'ifh'
    b'HsK4lUKf3eLBZ3vCMJ7/NK8Q3ncICWac5yYNgR'
    b'EsrHUGiDa1oGalWSAUFxF4'
    b'3bPK+t/Nx/3s8sUI5TncV6Phjk6Qrbr'
    b'Lc2Oqf98430ksu41ysu77TlrYU35'
    b'66uF/14eyQ37pbD/hbfBOxCl67ug'
    b'FHuxvxOAOI2RKZjPGE1tnUO/wGVqrO'
    b'nwtdVedHVzNOMuRhJM/uz2Rt'
    b'NhXrrUQ9XlsT8TOqOaeQDzk3FXhaAMfGe9'
    b'4CeyQVdPnrlg242DKIBAA8Wfog6p4do6sQ6Htt+ESHXR4RN'
    b'hcXmguJ+4p6cgCutbYIfaWDiRkOxruBjx'
    b'5SIbwTYOJ9F4WMi2kU6NsVmrBiaoLs8rHmDug8mFJuOHzC'
    b'iEY'
    b'jxW24b+Za0Ls+l+W7fBp2hPP7FZ4guY8fun0cJ6gqVa'
    b'ADB/zeVIIPQ72ox6pLGlqFLrR6iLn'
    b'ySN9qH9tJ5N'
    b'kP2Bakj5JYXotsBQm4C84gbMute6p+rySofW1pwfgHNNr'
    b'+uX2NysYGwXNxBW4SPUUx38Rf0c1ohlYaJIdb4'
    b'Sx4XJhD4qj4faWFMDCp'
    b'Yn6v97G6utgbIos/MmaM9kZyzxOHCLtylI'
    b'ioBDuuHmarySaH8t/8Pv5phrL6nm8hIski9gYda'
    b'T5aiER'
    b'iaXbYCe0'
    b'Aw7sXRN'
    b'6CQGd7zwKd4I2cEMKpSHZtkvG5JnezB8uOsT2clCDwtsVl'
    b'5z3ncbGROktTWkSJXBUJFc02AuJuDkuGbGL0K1uRIiXo'
    b'Rz04r1C0v6MS+1EymMsJ/DiLURq0ElE3N4Sue6326lX'
    b'21wTgx0RVRb48jNdGWrf3iIAmDP1'
    b'tZNK3'
    b'Pk8s+GFuwwUOHmOZlw/cDj7vSSCogYNGeAu'
    b'IrlY6'
    b'QI+lZz/9t'
    b'F3tSO0jtdV'
    b'2ISNrcom8YhvXczSr3aWze'
    b'PQabbMvq4T6SngSUNBlqmchKfecpj/WBvNZJDQM'
    b'8sLcTTluTU6'
    b'OgOKNGH56zz6o1LOS177ZyZtVS'
    b'FwBX8v8PKFvSLetOKLFOrEfvj9E9KRreCEeH8at'
    b't73SQ8yKoNv+AAj4FCBXY4E0uh/zBEpDrAy1g3D3j2FaNAy'
    b'CP+4Ml28Ap/J8nxQR9xwgejJDMvKb1gLZnMI'
    b'nt'
    b'D3/JLEMLzu7LlveTwo0koOvM4x7y4qT1GquP5X+1j'
    b'tihNX00NpC40g8fTOhsZrP44Ua2jl/lINtRst1o'
    b'XHW2NZn7oF6mOihhs13mNX8PrtTDjGAiVuPo0a'
    b'+jbWBguBmCLFq8dcle'
    b'cN7aahHLieEX1'
    b'sHtjfIj/0yy76sJ2mQTZrXlTgZ6Dn'
    b'N/t1Aj'
    b'egh2V8Gz81DPAH3/EN8B90eAkoW1ojVuMhub'
    b''
    b'z5GD1fzh'
    b'/J+O9IVKPhw3wF3001yKn1MOVEFVnuSDiwR0ip9T'
    b'z/WZHC5pNuL9GUAdnZLRgMrHz9u'
    b'k0DknE27ddWaTztgw+E3yl4KqTXTC5DrqS/U2'
    b'Sz++QSa8jFEUtM3HseCPtlD'
    b'yJW'
    b'mbxnIHJle7lUzqobqUZrF3Q6XLCWGfsMmnewO'
    b'RhnzAW6+EayPsOxOet82N7WVnpe1BDUU5SYVobV9olOmRKiWeh'
    b'jLtmzh/p4eVM'
    b'1AnVjK5z0ANnd+p'
    b'Wx5'
    b'Z/c7RWKCbLR4AMgySlbc66i9vs8yHKZcDPyToNCiPX5EbI4'
    b'kiDivrDF8mA7nhg7kaxgi86i+nEtmoATLqcutKr76OX8IMkTFE'
    b'5Z0M5grJ/1xcQIH0xUESJK6yyKM+bO75Pog'
    b'KDAFIaWeJXabIYmm6f/8/vX33//8/xP69zKn/y'
    b'Z///33r/8Ckm5WyHULAAA='
)).decode('utf-8'))

# -*- coding: utf-8 -*-
"""
@author: zzf
@file: main.py
@time: 2018/11/13
"""
import math
from collections import defaultdict
n, k = map(int, input().split())
a = list(map(int, input().split()))

m = defaultdict(int)

for i in range(n):
    m[a[i]] += 1

mx = 0
for key in m:
    if mx < m[key]:
        mx = m[key]
if mx % k == 0:
    t = mx // k
else:
    t = mx // k + 1

res = t*k*len(m) - n
print(res)

import math

n, k = (int(x) for x in input().split())
a = [int(x) for x in input().split()]
a.sort()
c = []
for i in range(1,101):
    c.append(a.count(i))

bl = math.ceil(max(c)/k)
ans = 0
for i in c:
    if i != 0:
        ans += bl * k - i
print(ans)

ligne = input().split(' ')
n = int(ligne[0])
k = int(ligne[1])
ligne = input().split(' ')
mat={}
max = 0
for i in range(n):
	mat[ligne[i]] = 0
for i in range(n):
	mat[ligne[i]] += 1
	if mat[ligne[i]]>max:
		max = mat[ligne[i]]
print (mat)
alls = max/k
if alls-int(alls) > 0:
	alls = int(alls) + 1
print ((alls*k*len(mat))-n)

n,k = map(int,input().split())
s = list(map(int,input().split()))
m = 1
for i in range(1,n):
    if s.count(i-1)>s.count(i):
        m = s.count(i-1)
r = set(s)
lr = len(r)
if m % k==0:
    we = m//k
else:
    we = m//k+1
qer = we*k*lr
print(abs(qer-n))

n, k = map(int, input().split())
lst = list(map(int, input().split()))
prib = set(lst)
maxcount = k
b = 1
for elem in prib:
    num = lst.count(elem)
    if num > maxcount:
        maxcount += k
        b += 1
        print(b * len(prib) * k - n)

from collections import Counter

I = lambda: map(int, input().split())

n, k = I()

print(sum(k*x if x%k else x for x in Counter(I()).values()) - n)

n, k = map(int, input().split())
lst = list(map(int, input().split()))
prib = set(lst)
maxcount = 0
b = 1
for elem in prib:
    num = lst.count(elem)
    if num > maxcount:
        maxcount += k
b = maxcount // k
print(b * len(prib) * k - n)

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

d = {}

for i in range(1, 101):
    d[i] = 0

s = 0
for i in range(n):
    d[l[i]] += 1
    s = s + 1

pr = 0

for i in d:
    if d[i] != 0:
        pr += 1

smax = 0

for i in d:
    if d[i] > smax:
        smax = i

if smax % m == 0:
    bl = smax // m
else:
    bl = smax // m + 1

print(bl*m*pr - s)

from collections import Counter
from math import ceil

n, k = [int(i) for i in input().split()]
arr = [int(i) for i in input().split()]

c = Counter(arr)

mx = 0
for i in range(len(arr)):
    if (c[i] > mx):
        mx = c[i]

a = ceil(mx/k)

t = a*k

sum = 0
for i in c:
    if(c[i] < t and c[i] != 0):
        sum+=(t-c[i])
print(sum)

n, k = list(map(int, input().split()))
sets = list(map(int, input().split()))
dish = sorted(set(sets))
d = dict()
c_d = 0
ans = 0
for i in dish:
    d[sets.count(i)] = i
c_d = max(d)
if c_d % k != 0:
    c_d = (c_d // k + 1) * k
for i in d:
    ans += c_d - i
print(ans)

from collections import Counter
from math import ceil

n,d = input().split()
n = int(n)
d = int(d)
x = list(map(int,input().split(' ')))
most_com = Counter(x).most_common()[0][1]
print(abs(ceil(most_com/d)*d*most_com-n))

n, k = map(int,input().split())
it = 0
s = input().split()
d = dict()
for i in range(n):
    if int(s[i]) in d :
        d[int(s[i])] += 1
    else :
        d[int(s[i])] = 1
for i in d.keys() :
    if d[i] % k != 0 :
        it += k - d[i] % k
print(it)

import math

d = dict()
n, k = map(int, input().split())

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

for i in mass:
    if str(i) in d:
        d[str(i)] += 1
    else:
        d[str(i)] = 1

print(abs(n - (math.ceil(max(list(d.values())) / k) * k * max(list(d.values())))))

n, m = map(int, input().split())
a = [int(i) for i in input().split()]
s = set(a)
t = len(s) // 2
a1 = []
c = 0
if m == 1:
  print(0)
else:
  for i in a:
    if a.count(i) == m * t and i not in a1:
      a1.append(i)
    elif i not in a1 and t != 0:
      c += m * t - a.count(i)
      a1.append(i)
    elif i not in a1 and t == 0:
      c += n % m
      a1.append(i)
  print(c)

from collections import defaultdict as dd
d=dd(lambda:0)
n,k=map(int,input().split())
l=list(map(int,input().split()))
for i in l:
	d[i]+=1
s=len(set(l))
a=max(d.values())
if a>k:
	print((s*(2*k))-n)

else:
	print(s*k-n)

n, m = map(int, input().split())
a = [int(i) for i in input().split()]
s = set(a)
t = len(s) // 2
a1 = []
c = 0
for i in a:
  if a.count(i) == m * t and i not in a1:
    a1.append(i)
  elif i not in a1 and t != 0:
    c += m * t - a.count(i)
    a1.append(i)
  elif i not in a1 and t == 0:
    c += n % m
    a1.append(i)
print(c)

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

sum = 0

co = [0 for _ in range(100)]

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

for i in l:
    co[i-1] += 1

for i in co:
    if i != 0:
        sum += k-i

print(sum)

n,k = list(map(int, input().split()))
ut = list(map(int, input().split()))
dict = {}
maximo = 0
roubos = 0

for i in range(n):
    if ut[i] in dict:
        dict[ut[i]] += 1
        maximo = max(dict[ut[i]],maximo)
    else:
        dict[ut[i]] = 1

while maximo%k:
    maximo+=1

print(len(dict)*maximo-n)

import math
def most_common(lst):
    res = dict((lst.count(i), i) for i in set(lst))
    return res[max(res.keys())]
a = []
a1 = []

n,k=map(int,input().split())
s = str(input()).split()
for i in range(len(s)):
    a.append(int(s[i]))
c=len(set(a))
a1=[str(i) for i in a]
x=most_common(a1)
nx=a1.count(x)
z= math.ceil(nx/k)
print(abs(z*nx*k-n))

n,k=map(int,input().split())
a=[int(j) for j in input().split()]
a.sort()
s=0
j=[]
maxi=a.count(a[0])
for i in range(len(a)):
    if a.count(a[i])>maxi:
        maxi=a.count(a[i])
u=maxi/k
if u!=int(u):
    u=int(u)+1
for i in range(len(a)):
    if j.count(a[i])==0:
        s+=u*k-a.count(a[i])
        j.append(a[i])
print(s)

guest, number = map(int, input().split())
a = list(map(int, input().split()))
b = set(a)
c = {i:a.count(i) for i in b}
m = 1
for i in c.values():
    if i > number:
        k = i // number + 1
    else:
        k = 1
    if k > m:
        m = k
print(len(b) * m * number - len(a))

n,k =map(int, input().split())
x = [int(i) for i in input().split()]
courses = 0
arr = []

for i in range (0,100):
    arr.append(0)

for i in range(0,n):
    arr[x[i]-1]=arr[x[i]-1]+1

sets =0
number_of_courses = 1
for i in range(0,100):
    if arr[i]>0:
        sets = sets+1
        if arr[i]>k:
            if number_of_courses <int(arr[i]/k)+1:
                number_of_courses = int(arr[i]/k)+1

print(int(number_of_courses*sets*k) - n)

n,k = map(int, input().split())
x = list(map(int, input().split()))
ans = [0 for i in range(1,101)]

for i in x :
	ans[i]=+1

m,mk=ans[0],0
for i in range(1,100):
	if m<ans[i]:
		m = ans[i]
		mk = i
pro = 0
if m <= k  :
	pro = 1
else:
	if m % k == 0 :
		pro = m / k
	else:
		pro = m//k+1

error = pro * k
s = 0
for i in ans :
	s = s + (error-i)
print(s)

n,k = [int(i) for i in input().split()]
mas = [int(i) for i in input().split()]
min1 = 999999
mas1 = []
for i in range(0,101):
    mas1.append(0)
for i in range(0,n):
    x = mas[i]
    mas1[x] += 1
for i in range(0,len(mas1)):
    if mas1[i] > 0 and mas1[i] < min1:
        min1 = mas1[i]
mas = set(mas)
z = len(mas)
min1 = k-min1
print ((z*k*min1)-n)

import math
guests=input().split()
utensil=input().split()
notstolen=[]
max=0
stolen=0
while utensil!=[]:
    counter=0
    skp=0
    y=utensil[0]
    for i in range (len(utensil)):
        if utensil[0+skp]==y:
            counter+=1
            utensil.pop(0+skp)
        else:
            skp+=1
    notstolen.append(counter)
    if counter>max:
        max=counter
test1=(int(guests[1]))
test2=(math.ceil(max/(int(guests[1]))))
test=test1*test2
print(test1)
print(test2)
print(notstolen)
for i in notstolen:
    stolen+=int(test)-i
print(stolen)

ligne = input().split(' ')
n = int(ligne[0])
k = int(ligne[1])
ligne = input().split(' ')
mat={}
max = 0
for i in range(n):
	mat[ligne[i]] = 0
for i in range(n):
	mat[ligne[i]] += 1
	if mat[ligne[i]]>max:
		max = mat[ligne[i]]
print (mat)
alls = max/k
if alls-int(alls) > 0:
	alls = int(alls) + 1
print ((alls*k*len(mat))-n)

a,b = map(int, input().split())
c = []
sett = 0
c = input()
c = c.split(" ")
for n in range(1,101):
    for i in c:
        if n == int(i):
            sett += 1
            break
maxrep = 1
for n in range(1,101):
    rep = 0
    for i in c:
        if n == int(i):
            rep += 1
            if rep > b:
                maxrep +=1
dish = maxrep * b * sett
pribor = len(c)
r = dish - pribor
print(r)

#!/usr/bin/env python
"""
This file is part of https://github.com/Cheran-Senthil/PyRival.

Copyright 2018 Cheran Senthilkumar all rights reserved,
Cheran Senthilkumar <hello@cheran.io>
Permission to use, modify, and distribute this software is given under the
terms of the MIT License.

"""
from __future__ import division, print_function

import cmath
import itertools
import math
import operator as op
# import random
import sys
from atexit import register
from bisect import bisect_left, bisect_right
from collections import Counter #, MutableSequence, defaultdict, deque
# from copy import deepcopy
# from decimal import Decimal
# from difflib import SequenceMatcher
# from fractions import Fraction
# from heapq import heappop, heappush

if sys.version_info[0] < 3:
    # from cPickle import dumps
    from io import BytesIO as stream
    # from Queue import PriorityQueue, Queue
else:
    # from functools import reduce
    from io import StringIO as stream
    from math import gcd
    # from pickle import dumps
    # from queue import PriorityQueue, Queue

if sys.version_info[0] < 3:
    class dict(dict):
        """dict() -> new empty dictionary"""
        def items(self):
            """D.items() -> a set-like object providing a view on D's items"""
            return dict.iteritems(self)

        def keys(self):
            """D.keys() -> a set-like object providing a view on D's keys"""
            return dict.iterkeys(self)

        def values(self):
            """D.values() -> an object providing a view on D's values"""
            return dict.itervalues(self)

    def gcd(x, y):
        """gcd(x, y) -> int
        greatest common divisor of x and y
        """
        while y:
            x, y = y, x % y
        return x

    input = raw_input
    range = xrange

    filter = itertools.ifilter
    map = itertools.imap
    zip = itertools.izip

def sync_with_stdio(sync=True):
    """Set whether the standard Python streams are allowed to buffer their I/O.

    Args:
        sync (bool, optional): The new synchronization setting.

    """
    global input, flush

    if sync:
        flush = sys.stdout.flush
    else:
        sys.stdin = stream(sys.stdin.read())
        input = lambda: sys.stdin.readline().rstrip('\r\n')

        sys.stdout = stream()
        register(lambda: sys.__stdout__.write(sys.stdout.getvalue()))

def main():
    n, k = map(int, input().split())
    a = Counter(map(int, input().split()))

    print((k * math.ceil(a.most_common(1)[0][1] / k) * len(a)) - sum(a.values()))

if __name__ == '__main__':
    sync_with_stdio(False)

    if 'PyPy' in sys.version:
        from _continuation import continulet

        def bootstrap(c):
            callable, arg = c.switch()
            while True:
                to = continulet(lambda _, f, x: f(x), callable, arg)
                callable, arg = c.switch(to=to)

        c = continulet(bootstrap)
        c.switch()

        main()

    else:
        import threading

        sys.setrecursionlimit(2097152)
        threading.stack_size(134217728)

        main_thread = threading.Thread(target=main)
        main_thread.start()
        main_thread.join()

n,k=map(int,input().split())
a=[int(x) for x in input().split()]

d=set(a)
dishes=n//len(d)
total=k*len(d)*dishes
stolen=total-n
print(stolen)

n, k = [int(x) for x in input().split()]
a = [int(x) for x in input().split()]
assert n == len(a)
b = {}
for i in range(n):
    if a[i] not in b:
        b[a[i]] = a.count(a[i])
d = max(b.values()) // k + 1
s = d * len(b) * k - n
print(s)

n,k=map(int,input().split())
a=[int(x) for x in input().split()]

d=set(a)
if(len(d)==1):
	dishes=n//k
else:
	dishes=n//len(d)
total=k*len(d)*dishes
stolen=total-n
print(stolen)

a,b=map(int,input().split())
k=list(map(int,input().split()))
d=[0]*100
for i in k:
    d[i-1]+=1
x=max(d)
s=0
for i in d:
    if i!=0:
        s+=x-i
n=set()
y=0
for i in k:
    if i not in n:
        n.add(i)
        y+=1
while (a+s)%b!=0:
    s+=y
print (s)

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

hashmap = {}

maxCount = 0
for item in arr:
    if item in hashmap:
        hashmap[item] += 1
        maxCount = max(maxCount, hashmap[item])
    else:
        hashmap[item] = 1

ost = maxCount % k
foodCount = int(maxCount / k)
if ost != 0:
    foodCount += 1

res = 0
for item in hashmap:
    res += k*foodCount - hashmap[item]

# print(hashmap)
print(res)

n, k = map(int, input().split())
a = [int(e) for e in input().split()]
q = dict()
mx = len(set(a))
res = 0
m = 1
for i in a:
    q[i] = q.get(i, 0) + 1
for i in a:
    if q[i] > k:
        m = q[i] / k
        if int(m) < m:
            m = int(m) + 1
mx = m * mx * k
print(mx - n)

n, k = input().split(' ')
pos = input().split(' ')
count = 0
maxim = 1
count1 = 0
u = []
for i in pos:
    if pos.count(i) > count:
        count = pos.count(i)
        if count > int(k):
            maxim = (count + int(k) - 1) // int(k)
count = count * maxim * int(k)
print(count - int(n))

def king():
    ns = [0] * 111
    inp = input().split()
    left = int(inp[0])
    guests = int(inp[1])
    lst = list(map(int, input().split()))
    for i in lst:
        ns[i] += 1
    # print(ns)
    m = max(ns)
    if m != guests:
        need = m + (guests - (m % guests))
    else: need = m
    res = 0
    for i in ns:
        if i != 0:
            res += (need - i)
    return res

print(king())

k,n=map(int,input().split())
a=list(map(int,input().split()))
a.sort()
b=[]
b.append(a.count(a[0]))
for i in range(1,k):
    if a[i]!=a[i-1]:
        b.append(a.count(a[i]))
b.sort()
nn=round((b[-1]+0.5)/n)
print(nn*n*len(b)-sum(b))

n,d=[int(s) for s in input().split()]
a=[int(s) for s in input().split()]
b=[]
k=0
c=[]
for i in range(max(a)):
	b.append(0)
for i in range(n):
	b[a[i]-1]+=1
for i in range(len(b)):
	if b[i]>0:
		c.append(b[i])
k=len(c)*d*(d-min(c))
ans=k-sum(c)
print(ans)

a = [int(s) for s in input().split()]
n, k = a[0], a[1]
things = [int(s) for s in input().split()]
a = {}
for thing in things:
    if thing not in a:
        a[thing] = 1
    else:
        a[thing] += 1

max_a = max(a.values())
compl = (max_a + max_a // k * k) // k * k
print(compl * len(a) - n)

from collections import Counter
from math import ceil

n, k = [int(i) for i in input().split()]
arr = [int(i) for i in input().split()]

c = Counter(arr)

mx = 0
for i in range(len(arr)):
    if (c[i] > mx):
        mx = c[i]

a = ceil(mx/k)
t = a*k

s = set(arr)
sum = 0
for i in s:
    if(c[i] < t):
        sum+=(t-c[i])

print(sum)

n,k = [int(i) for i in input().split()]
mas = [int(i) for i in input().split()]
min1 = 999999
mas = set(mas)
z = len(mas)
min1 = int(n//z)
print ((z*k*min1)-n)

n,k = map(int, input().split())
x = list(map(int, input().split()))
ans = [0 for i in range(1,101)]

for i in x :
	ans[i]=+1

m,mk=ans[0],0
for i in range(1,100):
	if m<ans[i]:
		m = ans[i]
		mk = i
pro = 0
if m <= k  :
	pro = 1
else:
	if m % k == 0 :
		pro = m / k
	else:
		pro = m//k+1

error = pro * k
s = 0
for i in ans :
	s = s + (error-i)
print(s)

import math

d = dict()
n, k = map(int, input().split())

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

for i in mass:
    if str(i) in d:
        d[str(i)] += 1
    else:
        d[str(i)] = 1

print(abs(n - (math.ceil(max(list(d.values())) / k) * k * max(list(d.values())))))

first = [int(num) for num in input().split()]
sec = input().split()
sec_2 = set(sec)
kol = []
for i in sec_2:
    kol.append(sec.count(i))
if max(kol) > first[1]:
    if len(sec_2) < first[1]:
        mn = (max(kol) // first[1])
        print(first[1] * mn * first[1] - first[0])
    else:
        mn = (max(kol) // first[1]) + 1
        print((len(sec_2)) * mn * first[1] - first[0])
else:
    print(first[1] * len(sec_2) - first[0])

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

hashmap = {}

maxCount = 0
for item in arr:
    if item in hashmap:
        hashmap[item] += 1
        maxCount = max(maxCount, hashmap[item])
    else:
        hashmap[item] = 1

ost = maxCount % k
foodCount = max(int(maxCount / k), 1)
if ost != 0:
    foodCount += 1

res = foodCount * k * len(hashmap) - n
# for item in hashmap:
#     res += k*foodCount - hashmap[item]

# print(hashmap)
print(res)

def king():
    ns = [0] * 111
    inp = input().split()
    left = int(inp[0])
    guests = int(inp[1])
    lst = list(map(int, input().split()))
    for i in lst:
        ns[i] += 1
    print(ns)
    m = max(ns)
    if m % guests != 0:
        need = m + (guests - (m % guests))
    else: need = m
    res = 0
    for i in ns:
        if i != 0:
            res += (need - i)
    return res

print(king())

n, k = map(int, input().split())
lst = list(map(int, input().split()))
prib = set(lst)
maxcount = k
ans = 0
for elem in prib:
    num = lst.count(elem)
    if num > maxcount:
        maxcount += k
for elem in prib:
    num = lst.count(elem)
    ans += maxcount - num
print(ans)

guest, number = map(int, input().split())
a = list(map(int, input().split()))
b = set(a)
c = {i:a.count(i) for i in b}
m = 1
for i in c.values():
    if i > number:
        k = i // number + 1
    else:
        k = number
    if k > m:
        m = k
print(len(b) * m * number - len(a))

import math
'''
line1 = input()
line2 = input()
'''

'''
line1 = "5 2"
line2 = "1 2 2 1 3"
'''

line1 = "10 3"
line2 = "1 3 3 1 3 5 5 5 5 100"

list1 = line1.split()
list2 = line2.split()
print(list1)
print(list2)

remaining = int(list1[0])
guests = int(list1[1])

print(str(remaining) + '\n' + str(guests))

countUtensils = {}
mx = 0
types = 0

for utensil in list2:
    if countUtensils.get(utensil, 0) == 0:
        types += 1
    countUtensils[utensil] = countUtensils.get(utensil, 0) + 1
    if countUtensils[utensil] > mx:
        mx = countUtensils[utensil]

dishes = math.ceil(mx / guests)
total = dishes * guests * types
print(total)
print(remaining)
print(total - remaining)

n,k = [int(i) for i in input().split()]
mas = [int(i) for i in input().split()]
min1 = 999999
mas = set(mas)
z = len(mas)
min1 = int(n/z)
print ((z*k*min1)-n)

data = input().split(' ')
n = int(data[0])
k = int(data[1])

line = input().split(' ')

form = []
count = []
all = 1

for foo in range(len(line)):
    if line[foo] not in form:
        form.append(line[foo])
        count.append(1)
    else:
        ind = form.index(line[foo])
        count[ind] += 1

max = 0

for bar in range(len(count)):
    if count[bar] > max:
        max = count[bar]
all = max // k + 1

s = n * k * all - n

print(s)

from collections import defaultdict
def gcd(a,b):
    if b==0: return a
    else: return gcd(b,a%b)
def LCM(a,b):
    return a*b/gcd(a,b)

n,k = tuple(map(int, input().split()))
arr = list(map(int,input().split()))
count = defaultdict(int)
for a in arr:
    count[a]+=1
mx = max(count.values())
total = mx * len(count)
lcm = LCM(mx,k)
i = 1
while lcm*i < total:
    i+=1
lcm = lcm*i
print(int(lcm-n))

l = list(map(int, input().split()))
n = l[0]
k = l[1]
cultery = list(map(int, input().split()))
cultery.sort()
m = 0
s = 1
types = 0

for i in range(len(cultery)):
    if cultery[i] == cultery[i-1]:
        s += 1
    else:
        if s > m: m = s
        s = 1
        types += 1

for_one = (m - 1) // k + 1
s = 0
st = for_one * types * k - n

print(st)

n, k = map(int, input().split())
a = [int(e) for e in input().split()]
q = dict()
mx = len(set(a))
res = 0
m = 1
for i in a:
    q[i] = q.get(i, 0) + 1
for i in a:
    if q[i] > k:
        m = q[i] / k
        if int(m) < m:
            m = int(m) + 1
mx = m * mx * k
print(mx - n)

a = input().split()
bb = input().split()
from collections import Counter
counter = Counter(bb).most_common(1)[0]
count_tips_priborov=counter[1]

vid = len(set(bb))
bluda = 0
x=int(bluda*int(a[1]))
y=int((count_tips_priborov // int(a[1]) + 1))
while bluda*int(a[1])<count_tips_priborov:
    bluda += 1
    if bluda*int(a[1])>=count_tips_priborov:
        ukrali=bluda*int(a[1])*vid-int(a[0])
        print(ukrali)
        break
    print(bluda)

n,k=map(int,input().split())
a=input().split()
D={}
for i in a:
    if i in D:
        D[i]+=1
    else:
        D[i]=1
gostu_max=max(D.values())
if k%gostu_max==0:
    bluda=gostu_max//k
else:
    bluda=(gostu_max//k)+1
b=bluda*k*len(D)
print(b-n)

[n,k] = [int(x) for x in input().split()]
a = [int(x) for x in input().split()]
b = [0 for i in range(0,101)]
for i in range(0,n):
    b[a[i]] += 1
num = 0
maxi = 0
m = 0
#print(a)
#print(b)
for j in range(0,101):
    if b[j] != 0 and b[j] == k:
        maxi = max(maxi,1)
        m += 1
    if b[j] != 0 and b[j] != k:
        maxi = max(maxi,b[j]//k+1)
        m += 1
#print(m)
#print(maxi)
num = maxi*k*m
print(num-n)

n, k = [int(i) for i in input().split()]
a = [int(i) for i in input().split()]

food = 1
s = dict()
result = 0

for i in range(n):
    ans = 0
    if a[i] not in s:
        s[a[i]] = 1
    else:
        ans += s[a[i]] + 1
        s[a[i]] = ans

arr = []

for key in s:
    if s[key] > k:
        arr.append(s[key])

if len(arr) > 0:
    maxArr = max(arr)
    while maxArr > k:
        food += 1
        maxArr -= k
    for key in s:
        result += (k * food) - s[key]
else:
    for key in s:
        arr.append(s[key])
    maxArr = max(arr)
    for i in range(len(arr)):
        result += maxArr - arr[i]

print(result)

from collections import Counter
from math import ceil

n, k = [int(i) for i in input().split()]
arr = [int(i) for i in input().split()]

c = Counter(arr)

mx = 0
for i in range(len(arr)):
    if (c[i] > mx):
        mx = c[i]

a = ceil(mx/k)

t = a*k

sum = 0
for i in c:
    if(c[i] < t and c[i] != 0):
        sum+=(t-c[i])
print(sum)

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

hashmap = {}

maxCount = 0
for item in arr:
    if item in hashmap:
        hashmap[item] += 1
        maxCount = max(maxCount, hashmap[item])
    else:
        hashmap[item] = 1

ost = maxCount % k
foodCount = max(int(maxCount / k), 1)
if ost != 0:
    foodCount += 1

res = 0
for item in hashmap:
    res += k*foodCount - hashmap[item]

print(res)

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

temp = set([i for i in range(1,101)])

unique = set(mass)&temp

count = [mass.count(i) for i in unique]
maxx = max(count)
blud = 1
if maxx>k:
    blud = maxx//k+1

prib = len(unique)

print(k*blud*prib-n)

l = list(map(int, input().split()))
n = l[0]
k = l[1]
cultery = list(map(int, input().split()))
cultery.sort()
m = 1
s = 1
types = 1

for i in range(1, len(cultery)):
    if cultery[i] == cultery[i-1]:
        s += 1
    else:
        if s > m: m = s
        s = 1
        types += 1

for_one = (m - 1) // k + 1
s = 0
st = for_one * types * k - n

print(st)

n,k=map(int,input().split())
li=list(map(int,input().split()))
m=0
for i in list(set(li)):
 if li.count(i)>m:
  m=li.count(i)
dishes=0
if m%k==0:
 dishes=m
else:
 s=(n+k-1)//k
 dishes=k*s
print((dishes*len((set(li))))-n)

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

hashmap = {}

maxCount = 0
for item in arr:
    if item in hashmap:
        hashmap[item] += 1
        maxCount = max(maxCount, hashmap[item])
    else:
        hashmap[item] = 1

priborInFood = len(hashmap)
priborPodacha = priborInFood * k
res = 0
allPribor = priborPodacha
i = 0
while maxCount > 0:
    i = i + 1
    maxCount = maxCount - k

res = priborPodacha * i - n

# ost = maxCount % k
# foodCount = max(int(maxCount / k), 1)
# if ost != 0:
#     foodCount += 1
#
# res = foodCount * k * len(hashmap) - n
# for item in hashmap:
#     res += k*foodCount - hashmap[item]

# print(hashmap)
print(res)

def find(arr,n,k):
  d = {}
  m = 0
  for a in arr:
    if a in d:
      d[a]+=1
    else:
      d[a]=1
    if m < d[a]:
      m = d[a]
  s = len(d)
  m = m%k + 1
  if s == 1 and m == 1:
    return 0
  if m > 0:
    return s*m*k-len(arr)
  return s*k-len(arr)

def main():
  n,k = map(int,input().split())
  arr = list(map(int,input().split()))
  print(find(arr,n,k))

if __name__=="__main__":
  main()

n, k = map(int, input().split())
lst = list(map(int, input().split()))
prib = set(lst)
maxcount = 0
b = 1
for elem in prib:
    num = lst.count(elem)
    if num > maxcount:
        maxcount += k
b = maxcount // k
print(b * len(prib) * k - n)

n, k = [int(x) for x in input().split()]
a = [int(x) for x in input().split()]
assert n == len(a)
b = {}
for i in range(n):
    if a[i] not in b:
        b[a[i]] = a.count(a[i])
d = max(b.values()) // k + 1
s = d * len(b) * k - n
print(s)

def king():
    ns = [0] * 111
    inp = input().split()
    left = int(inp[0])
    guests = int(inp[1])
    lst = list(map(int, input().split()))
    for i in lst:
        ns[i] += 1
    print(ns)
    m = max(ns)
    if m % guests != 0:
        need = m + (guests - (m % guests))
    else: need = m
    res = 0
    for i in ns:
        if i != 0:
            res += (need - i)
    return res

print(king())

from collections import Counter
import math
utensils, m = map(int, input().split(" "))
data = list(map(int, input().split(" ")))
dishes = 0
count = Counter(data)

#print(count.get(1))

for x in count:
    if(count[x] >= m):
        if(math.ceil(count[x]/m) > dishes):
            dishes = math.ceil(count[x]/m)

print((dishes * len(set(data)) * m) - utensils)

n, k = map(int, input().split())
lst = list(map(int, input().split()))
prib = set(lst)
ans = 0
maxcount = 0
for elem in prib:
    num = lst.count(elem)
    if num > maxcount:
        maxcount += k
for elem in prib:
    num = lst.count(elem)
    ans += maxcount - num
print(ans)

n, k = map(int, input().split())
unique_numbers = set()
countList = [0] * 101
input_list = list(map(int, input().split()))
for i in range(n):
    inValue = input_list[i]
    unique_numbers.add(inValue)
    countList[inValue] += 1
max_count = max(countList)
new_list = countList[:]
coefficient = 1
for i in range(len(new_list)):
    if (not new_list[i] % k == 0) and new_list[i] > k:
        t = new_list[i] // k
        new_list = [j * (t + 1) for j in new_list]
        coefficient += t

stolen = 0
for i in range(len(new_list)):
    stolen += new_list[i] - countList[i]

for i in range(len(new_list)):
    if not new_list[i] % k == 0:
        t = new_list[i] // k
        stolen += k * (t + 1) - new_list[i]

print(stolen)

n, k = input().split(' ')
pos = input().split(' ')
count = 0
maxim = 1
count1 = 0
u = []
for i in pos:
    if pos.count(i) > count:
        count = pos.count(i)
        if count > int(k):
            maxim = (count + int(k) - 1) // int(k)
count = count * maxim * int(k)
print(count - int(n))

utensils=[]
index,sum,N=0,0,2
n,k=input().split()
n=int(n)
k=int(k)
utensils=input().split()
utensils=[int(i) for i in utensils]
utensils.sort()
while index < len(utensils):
    num=utensils.count(utensils[index])
    sum=k-num+sum
    if (k-num)<0:
        k=k*N
        N=N+1
        index=0
        sum=0
        continue
    index=utensils.count(utensils[index])+index
print(sum)

i=input()
arr=[int(x) for x in i.split()]
n,k=arr[0],arr[1]
j=input()
arr1=[int(x) for x in i.split()]
for i in arr1:
    print(i)

n, k = map(int,input().split())
a = list(map(int,input().split()))
nabor = list(set(a))
kol = {}
maxi = 0
for i in a:
    if i in kol:
        kol[i] += 1
        if kol[i] > maxi:
            maxi = kol[i]
    else:
        kol[i] = 1
if (maxi % k == 0):
    ito = maxi
else:
    ito = (maxi // k + 1) * k
print(ito * len(nabor) - n)

from collections import Counter
n,k=map(int,input().strip().split())
arr=list(map(int,input().strip().split()))
dct=Counter(arr)

values = list(dct.values())
keys=list(dct.keys())
maxi=max(values)//2
total=len(keys)*maxi*k
print(total-n)

n, m = map(int, input().split())
a = [int(i) for i in input().split()]
s = set(a)
t = len(s) // 2
a1 = []
c = 0
if m == 1:
  print(0)
else:
  for i in a:
    if a.count(i) == m * t and i not in a1:
      a1.append(i)
    elif i not in a1 and t != 0:
      c += m * t - a.count(i)
      a1.append(i)
    elif i not in a1 and t == 0:
      c += n % m
      a1.append(i)
  print(c)

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

d = {}

for i in range(1, 101):
    d[i] = 0

s = 0

for i in range(n):
    d[l[i]] += 1
    s = s + 1

pr = 0

for i in d:
    if d[i] != 0:
        pr += 1

smax = 0

for i in d:
    if d[i] > smax:
        smax = i

if smax % m == 0:
    bl = smax // m
else:
    bl = smax // m + 1

print(max(bl*m*pr - s,0))

k,n=map(int,input().split())
a=list(map(int,input().split()))
a.sort()
b=[]
b.append(a.count(a[0]))
for i in range(1,k):
    if a[i]!=a[i-1]:
        b.append(a.count(a[i]))
b.sort()
nn=round((b[-1]+0.5)/n)
print(nn*n*len(b)-sum(b))

n,k = list(map(int, input().split()))
ut = list(map(int, input().split()))
list = [0]*101
maximo = 0
dif = 0

for i in range(n):
    if list[ut[i]] == 0:
        list[ut[i]] = 1
        dif += 1
    else:
        list[ut[i]]+=1
        maximo = max(list[ut[i]],maximo)

while maximo%k:
    maximo+=1

print(dif*maximo-n)

ligne = input().split(' ')
n = int(ligne[0])
k = int(ligne[1])
ligne = input().split(' ')
mat={}
max = 0
for i in range(n):
	mat[ligne[i]] = 0
for i in range(n):
	mat[ligne[i]] += 1
	if mat[ligne[i]]>max:
		max = mat[ligne[i]]
print (mat)
alls = max/k
if alls-int(alls) > 0:
	alls = int(alls) + 1
print ((alls*k*len(mat))-n)

n, k = map(int, input().split())
a = list(map(int, input().split()))
d = dict()
for i in a:
    if i not in d.keys():
        d[i] = 1
    else:
        d[i] += 1
t = max(d.values())
xxx = []
for i in range(1, t // 2 + 1):
    if t % i == 0:
        xxx.append(i)
        if t // i != t:
            xxx.append(t // i)
t = max(xxx)
x = 0
for i in d.values():
    x += t - i
print(len(d.keys()) * k * t - n)

def error():
    print("Bad input.");exit()

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

test = {1:n not in range(1,101),
        2:k not in range(1,101),
        3:n != len(a),
        4:any([i not in range(1,101) for i in a]),
        }
if any(test.values()):
    error()

kol = 1
ra = {key:a.count(key) for key in set(a)}
if max(ra.values()) > k:
    kol += max(ra.values()) // k

print(kol*k*len(set(a)) - 10)

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

cnt_of = [0] * 100
not_zeroes = []
cnt_diff = 0
for v in a:
	v -= 1
	cnt_of[v] += 1
	if cnt_of[v] == 1:
		cnt_diff += 1
for v in range(100):
	if cnt_of[v] > 0:
		not_zeroes.append(cnt_of[v])
at_least = max(k - min(not_zeroes), 1)

must_be = at_least * k * cnt_diff
print(max(must_be - n, 0))

import math

line1 = input()
line2 = input()
line2 = "1 3 3 1 3 5 5 5 5 100"

list1 = line1.split()
list2 = line2.split()
remaining = int(list1[0])
guests = int(list1[1])

countUtensils = {}
mx = 0
types = 0

for utensil in list2:
    if countUtensils.get(utensil, 0) == 0:
        types += 1
    countUtensils[utensil] = countUtensils.get(utensil, 0) + 1
    if countUtensils[utensil] > mx:
        mx = countUtensils[utensil]

dishes = math.ceil(mx / guests)
total = dishes * guests * types
print(total - remaining)

import math
n, k = map(int, input().split())
a = input().split()
items = set(a)
count = 0
answ = 0
for item in items:
    if a.count(item) > count:
        count = a.count(item)
max = math.ceil(count/k)*k
print(max)
for item in items:
    answ += max-a.count(item)

print(answ)