#include <stdio.h>
#include <stdlib.h>

int main()
{
    long int n,x,i,a[100000],min=32000,max=-32000,counter=0;
    scanf("%ld %ld", &n , &x);
    for(i=0;i<n;i++)
    {
        scanf("%ld", &a[i]);
    }
    for(i=0;i<n;i++)
    {
        if(a[i]<min)
        {
            min =a[i];
        }
        if(a[i]>max)
        {
            max = a[i];
        }




    }
    if(min<x)
                {
                    for(i=x;i>min;i--)
                    {
                        counter++;

                    }
                    printf("%ld\n",counter+max-min);

                }
                else
                {
                    printf("%ld",max-x);
                }


    return 0;
}