Students in a class are making towers of blocks. Each student makes a (non-zero) tower by stacking pieces lengthwise on top of each other. *n* of the students use pieces made of two blocks and *m* of the students use pieces made of three blocks.

The students don’t want to use too many blocks, but they also want to be unique, so no two students’ towers may contain the same number of blocks. Find the minimum height necessary for the tallest of the students' towers.
The first line of the input contains two space-separated integers *n* and *m* (0 ≤ *n*, *m* ≤ 1 000 000, *n* + *m* &gt; 0) — the number of students using two-block pieces and the number of students using three-block pieces, respectively.
In the first case, the student using two-block pieces can make a tower of height 4, and the students using three-block pieces can make towers of height 3, 6, and 9 blocks. The tallest tower has a height of 9 blocks.

In the second case, the students can make towers of heights 2, 4, and 8 with two-block pieces and towers of heights 3 and 6 with three-block pieces, for a maximum height of 8 blocks.
1 3
9
3 2
8
5 0
10
4 2
9
0 1000000
3000000
1000000 1
2000000
1083 724
2710
1184 868
3078
1285 877
3243
820189 548173
2052543
968867 651952
2431228
817544 553980
2057286
813242 543613
2035282
961920 647392
2413968
825496 807050
2448819
974174 827926
2703150
969872 899794
2804499
818549 720669
2308827
967227 894524
2792626
185253 152723
506964
195173 150801
518961
129439 98443
341823
163706 157895
482402
197973 140806
508168
1000000 1000000
3000000
1000000 999999
2999998
999999 1000000
3000000
500000 500100
1500300
500000 166000
1000000
500000 499000
1498500
500000 167000
1000500
1 1000000
3000000
2 999123
2997369
10 988723
2966169
234 298374
895122
2365 981235
2943705
12345 981732
2945196
108752 129872
389616
984327 24352
1968654
928375 1253
1856750
918273 219
1836546
987521 53
1975042
123456 1
246912
789123 0
1578246
143568 628524
1885572
175983 870607
2611821
6 4
15
6 3
14
7 3
15
5 4
14
5 3
12
8 5
20
1 0
2
19170 15725
52342
3000 2000
7500
7 4
16
50 30
120
300 200
750
9 4
20
4 3
10
1 1
3
8 6
21
10 6
24
65 56
182
13 10
34
14 42
126
651 420
1606
8 9
27
15 10
38
999999 888888
2833330
192056 131545
485402
32 16
72
18 12
45
1000000 666667
2500000
0 1
3
9 5
21
1515 1415
4395
300000 200000
750000
n, m = map(int, input().split())
l = []
x = 2
y = m
for i in range(n):
    if (x) % 3 != 0 or y <= 0:
        l.append(x)
        x += 2
    else:
        l.append(x + 2)
        y -= 1
        x += 4
maxm_m = m * 3
if n > 0:
    ans1=(max(maxm_m, l[-1]))
else:
    ans1 = (maxm_m)
l = []
x = 3
y = n
for i in range(m):
    if x % 2 != 0 or y <= 0:
        l.append(x)
        x += 3
    else:
        l.append(x + 3)
        y -= 1
        x += 6
maxm_n = n * 2
if m > 0:
    ans2=max(maxm_n, l[-1])
else:
    ans2 = (maxm_n)

print(min(ans2, ans1))