#include<cstdio>
using namespace std;
int n, s, l, r, last;
long long ans, x[100001], p[100001];
int main()
{
    scanf("%d%d", &n, &s);
    for (int i = 1; i <= n; ++i)
    {
        scanf("%lld%lld", &x[i], &p[i]);
    }
    l = 1;
    r = n;
    while (l <= r)
    {
        if (s <= x[l])
        {
            ans += x[r] - s;
            break;
        }
        if (s >= x[r])
        {
            ans += s - x[l];
            break;
        }
        ans += x[r] - x[l];
        if (p[l] >= p[r]) 
        {
			while (l < r && p[l] >= p[r])
            {
				p[l] += p[r];
                r--;
            }
		} 
        else 
			while (l < r && p[l] < p[r])
            {
				p[r] += p[l];
                l++;
            }
    }
    printf("%lld\n", ans);
}