#include <math.h>
#include <iomanip>
#include <iostream>
using namespace std;

int main()
{
	int n, m, inputs, a, i, a1, x, nule, jedinice, s, brojac;
	inputs = 0;
	nule = 0;
	jedinice = 0;
	i = 0;
	s = 0;
	cin >> n >> m;
	int *A = new int[n * m];
	while (n > inputs)
	{
		cin >> a;
		inputs++;
		a1 = a;
		while (a > 0)
		{
			A[i] = 1;
			i++;
		    a--;
		}
		while (a1 < m)
		{
			A[i] = 0;
			i++;
			a1++;
		}
	}
	i = 0;
	x = 0;
	brojac = 0;
	while (i < m)
	{
		while (brojac < n)
		{
			if (A[x] == 0)
			{
				nule++;
			}
			else
			{
				jedinice++;
			}
			brojac++;
			x = x + m;
		}
		s = s + (nule * 1);
		nule = 0;
		jedinice = 0;
		brojac = 0;
		i++;
		x = i;
	}
	cout << s;
	delete A;
}