using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace ConsoleApp1
{
    class Program
    {
        static void Main(string[] args)
        {
            string[] s = Console.ReadLine().Split();

            int n = Convert.ToInt32(s[0]);
            int x = Convert.ToInt32(s[1]);

            int[] a = new int[n + 1];

            s = Console.ReadLine().Split();

            for (int i = 0; i < n; i++)
            {
                a[i] = Convert.ToInt32(s[i]);
            }

            int max = a[0];
            int min = 100000001;


            for (int i = 0; i < n; i++)
            {
                if (a[i]>max)
                {
                    max = a[i];
                }

                if (a[i]<min)
                {
                    min = a[i];
                }
            }

           

            int br = 0;

            if (min < x)
            {
                if (max > x)
                {
                    br = x - min + max - x + 1;
                }
                else
                {
                    br = x - min;
                }

            }
            else
            {
                br = max - x;
            }

            Console.WriteLine(Convert.ToString(Math.Abs(br)));


        }
    }
}