Among other things, Bob is keen on photography. Especially he likes to take pictures of sportsmen. That was the reason why he placed himself in position *x*<sub class="lower-index">0</sub> of a long straight racetrack and got ready to take pictures. But the problem was that not all the runners passed him. The total amount of sportsmen, training at that racetrack, equals *n*. And each of them regularly runs distances within a particular segment of the racetrack, which is the same for each sportsman. For example, the first sportsman runs from position *a*<sub class="lower-index">1</sub> to position *b*<sub class="lower-index">1</sub>, the second — from *a*<sub class="lower-index">2</sub> to *b*<sub class="lower-index">2</sub>

What is the minimum distance that Bob should move to have a chance to take pictures of each sportsman? Bob can take a picture of a sportsman, if he stands within the segment that this sportsman covers on the racetrack.
The first line of the input file contains integers *n* and *x*<sub class="lower-index">0</sub> (1 ≤ *n* ≤ 100; 0 ≤ *x*<sub class="lower-index">0</sub> ≤ 1000). The following *n* lines contain pairs of integers *a*<sub class="lower-index">*i*</sub>, *b*<sub class="lower-index">*i*</sub> (0 ≤ *a*<sub class="lower-index">*i*</sub>, *b*<sub class="lower-index">*i*</sub> ≤ 1000; *a*<sub class="lower-index">*i*</sub> ≠ *b*<sub class="lower-index">*i*</sub>).
3 3
0 7
14 2
4 6
1
1 1
0 10
0
2 2
1 2
3 2
0
3 2
1 2
2 3
3 4
-1
2 4
10 4
1 5
0
1 10
1 9
1
1 10
123 12
2
1 17
10 17
0
1 22
22 33
0
1 3
1 2
1
2 5
0 3
2 1
3
3 3
7 3
6 4
3 7
1
4 9
8 6
11 5
5 11
8 3
1
2 4
1 4
4 0
0
3 7
5 8
7 5
4 7
0
4 7
8 2
5 7
8 2
5 8
0
2 3
4 1
4 1
0
3 8
7 2
3 7
5 2
3
4 0
9 1
8 1
8 4
4 5
4
4 7
2 5
3 6
3 5
7 4
2
10 16
4 18
6 19
22 1
23 0
1 22
9 22
4 19
0 14
6 14
0 16
2
20 1
35 8
40 6
49 5
48 18
46 16
45 16
44 10
16 44
8 46
2 45
38 3
42 1
13 35
35 18
12 33
32 11
31 3
50 20
47 6
38 2
19
30 43
17 72
75 26
23 69
83 30
15 82
4 67
83 27
33 62
26 83
70 26
69 25
16 67
77 26
66 33
7 88
70 9
10 79
76 9
30 77
77 28
21 68
81 14
13 72
88 15
60 29
87 28
16 58
6 58
71 9
83 18
0
40 69
29 109
28 87
52 106
101 34
32 92
91 60
90 47
62 102
33 72
27 87
45 78
103 37
94 33
56 98
38 79
31 83
105 53
47 89
50 83
93 62
96 49
47 75
89 47
89 61
93 54
46 100
110 41
103 28
101 57
100 62
71 37
65 80
86 28
73 42
96 44
33 111
98 39
87 55
108 65
31 101
0
50 77
95 55
113 33
101 17
109 56
117 7
77 12
14 84
57 101
96 28
108 22
105 12
17 114
51 115
18 112
104 25
50 115
14 111
55 113
124 20
101 37
18 121
41 90
77 41
117 16
8 83
92 45
48 86
16 84
13 98
40 107
14 94
23 111
36 121
50 100
35 90
103 37
96 51
109 15
13 117
117 42
112 45
88 36
51 121
127 49
112 15
9 95
122 46
126 40
57 93
56 88
0
5 12
2 7
7 5
3 10
11 3
2 11
5
15 15
12 37
40 4
38 8
5 36
11 31
21 33
9 37
4 38
8 33
5 39
7 39
38 16
16 41
38 9
5 32
6
25 40
66 26
56 19
64 38
64 23
25 49
51 26
67 20
65 35
33 66
28 63
27 57
40 56
59 26
35 56
39 67
30 63
69 22
21 63
67 22
20 66
26 65
64 26
44 57
57 41
35 50
4
50 77
24 119
43 119
102 22
117 30
127 54
93 19
120 9
118 27
98 16
17 105
22 127
109 52
115 40
11 121
12 120
113 30
13 108
33 124
31 116
112 39
37 108
127 28
127 39
120 29
19 114
103 18
106 16
24 121
93 10
36 112
104 40
39 100
36 97
83 9
14 114
126 12
85 47
25 84
105 29
35 113
102 19
8 110
111 28
94 12
11 115
40 124
39 85
47 93
94 31
17 121
0
1 21
973 373
352
2 212
831 551
810 753
541
3 404
690 728
820 260
186 402
-1
4 906
548 906
830 457
228 638
464 167
-1
5 97
97 393
840 965
269 183
596 49
975 62
-1
3 183
416 335
773 648
434 198
-1
3 868
251 927
862 464
157 756
112
3 242
397 208
951 279
570 622
-1
3 618
543 800
38 94
293 179
-1
3 993
378 81
127 911
16 737
615
5 12
11 1
9 6
1 11
3 8
874 842
-1
15 16
11 40
5 32
5 31
36 10
34 9
43 6
28 6
34 8
43 15
9 28
14 34
34 6
7 31
31 14
68 478
-1
25 57
47 31
64 21
43 56
47 19
70 27
28 61
41 61
39 45
46 21
55 35
70 22
22 69
30 67
55 42
37 58
50 28
57 42
35 48
68 40
38 50
62 20
31 52
38 70
64 35
666 393
-1
50 118
83 55
101 33
89 17
97 56
105 7
65 12
14 72
57 89
84 28
96 22
93 12
17 102
51 103
18 100
92 25
50 103
14 99
55 101
112 20
89 37
18 109
41 78
65 41
105 16
8 71
80 45
48 74
16 72
13 86
40 95
14 82
23 99
36 109
50 88
35 78
91 37
84 51
97 15
13 105
105 42
100 45
76 36
51 109
115 49
100 15
9 83
110 46
114 40
57 81
528 348
-1
1 21
0 1000
0
import sys
input = sys.stdin.readline

n, x = map(int, input().split())
s = []
l, r = 0, 0
for _ in range(n):
    a, b = map(int, input().split())
    if a > b:
        a, b = b, a
    if not a <= x <= b:
        if x < a:
            r = max(r, a - x)
        else:
            l = max(l, x - b)
ans = l + r + min(l, r)
print(ans)