Finished her homework, Nastya decided to play computer games. Passing levels one by one, Nastya eventually faced a problem. Her mission is to leave a room, where a lot of monsters live, as quickly as possible.

There are $n$ manholes in the room which are situated on one line, but, unfortunately, all the manholes are closed, and there is one stone on every manhole. There is exactly one coin under every manhole, and to win the game Nastya should pick all the coins. Initially Nastya stands near the $k$-th manhole from the left. She is thinking what to do.

In one turn, Nastya can do one of the following:   if there is at least one stone on the manhole Nastya stands near, throw exactly one stone from it onto any other manhole (yes, Nastya is strong).  go to a neighboring manhole;  if there are no stones on the manhole Nastya stays near, she can open it and pick the coin from it. After it she must close the manhole immediately (it doesn't require additional moves). 

 [Image] The figure shows the intermediate state of the game. At the current position Nastya can throw the stone to any other manhole or move left or right to the neighboring manholes. If she were near the leftmost manhole, she could open it (since there are no stones on it). 

Nastya can leave the room when she picks all the coins. Monsters are everywhere, so you need to compute the minimum number of moves Nastya has to make to pick all the coins.

Note one time more that Nastya can open a manhole only when there are no stones onto it.


-----Input-----

The first and only line contains two integers $n$ and $k$, separated by space ($2 \leq n \leq 5000$, $1 \leq k \leq n$) — the number of manholes and the index of manhole from the left, near which Nastya stays initially. Initially there is exactly one stone near each of the $n$ manholes. 


-----Output-----

Print a single integer — minimum number of moves which lead Nastya to pick all the coins.


-----Examples-----
Input
2 2

Output
6

Input
4 2

Output
13

Input
5 1

Output
15



-----Note-----

Let's consider the example where $n = 2$, $k = 2$. Nastya should play as follows:

  At first she throws the stone from the second manhole to the first. Now there are two stones on the first manhole.  Then she opens the second manhole and pick the coin from it.  Then she goes to the first manhole, throws two stones by two moves to the second manhole and then opens the manhole and picks the coin from it. 

So, $6$ moves are required to win.

Difficulty: interview

Starter code:

Solutions:
n, k = list(map(int,input().split()))
if k == 1 or k == n:
    print(3 * n)
else:
    print(3 * n + min(k - 1, n - k))


l = list(map(int, input().split()))
print(3*l[0]+min(l[1]-1,l[0]-l[1]))


import getpass
import math
import sys
import string
import re
import math
import random
from decimal import Decimal, getcontext


def ria():
    return [int(i) for i in input().split()]


if getpass.getuser() != 'frohenk':
    filename = 'half'
    # sys.stdin = open('input.txt')
    # sys.stdout = open('output.txt', 'w')
else:
    sys.stdin = open('input.txt')
    # sys.stdin.close()

n, k = ria()
rcks = n + 1
mny = n
mvs = min((k - 1) * 2 + (n - k), (k - 1) + (n - k) * 2)

if k == 1:
    mvs = n - 1

if k == n:
    mvs = n - 1
    
print(mvs + rcks + mny)


n, k = map(int, input().split())
ans = 2 * n + 1
ans += n - 1 + min(k - 1, n - k)
print(ans)

n,k = list(map(int,input().split()))

if k == 1:
    print(3*(n-1)+3)
elif k == n:
    print(3*(n-1)+3)

else:
    shorter = min(k-1,n-k)
    longer = max(k-1,n-k)
    out = 0
    out += shorter*3 + shorter + longer*3 +3
    print (out)


ii = lambda: int(input())
mi = lambda: map(int, input().split())
li = lambda: list(mi())

n, k = mi()
if k - 1 > n - k:
    k = n - k + 1

ans = n + k - 1 + 1 + n + n - 1
print(ans)

# -*- coding: utf-8 -*-


def rli():
    return list(map(int, input().split()))


def main():
    n, k = rli()
    ans = n * 3
    if k != n and k != 1:
        ans += min(n - k, k - 1)
    print(ans)


def __starting_point():
    main()

__starting_point()

n, k = list(map(int, input().split()))
print(n * 3 + min(k, n + 1 - k) - 1)


n,k=[int(x) for x in input().split()]
print(min(n-k,k-1)+3*n)


n,k=list(map(int,input().split()))
diff1=k-1
diff2=n-k
ans=2
if(diff1<=diff2):
	ans+=4*(diff1)
	ans+=1
	ans+=3*(diff2)
else:
	ans+=4*(diff2)
	ans+=1
	ans+=3*(diff1)
print(ans)


N, K = list(map(int, input().split()))
print(3*N+min(K-1, N-K))


n, k = map(int, input().split())
print(n + min(k-1, n-k) + n + n)

#      
import collections, atexit, math, sys, bisect 

sys.setrecursionlimit(1000000)

isdebug = False
try :
    #raise ModuleNotFoundError
    import pylint
    import numpy
    def dprint(*args, **kwargs):
        #print(*args, **kwargs, file=sys.stderr)
        # in python 3.4 **kwargs is invalid???
        print(*args,  file=sys.stderr)
    dprint('debug mode')
    isdebug = True
except Exception:
    def dprint(*args, **kwargs):
        pass


def red_inout():
    inId = 0
    outId = 0
    if not isdebug:
        inId = 0
        outId = 0
    if inId>0:
        dprint('use input', inId)
        try:
            f = open('input'+ str(inId) + '.txt', 'r')
            sys.stdin = f #标准输出重定向至文件
        except Exception:
            dprint('invalid input file')
    if outId>0:
        dprint('use output', outId)
        try:
            f = open('stdout'+ str(outId) + '.txt', 'w')
            sys.stdout = f #标准输出重定向至文件
        except Exception:
            dprint('invalid output file')
            
        atexit.register(lambda :sys.stdout.close())     #idle 中不会执行 atexit

if isdebug and len(sys.argv) == 1:
    red_inout()

def getIntList():
    return list(map(int, input().split()))            

def solve(): 
    pass
    
T_ = 1    
#T_, = getIntList()

for iii_ in range(T_):
    #solve()
    N, K = getIntList()
    #print(N)
    r = N+1
    r+= N
    r +=N
    r += min(K-1, N-K) -1
    print(r)
    








n, k = map(int, input().split())
k -= 1

go_to_border = min(k, n-k-1)
more = 3 * n
print(go_to_border + more)

n, k = list(map(int, input().split()))
ans = 0
if k != 1 and k != n:
    ans = 2 * min(k - 1, n - k) + max(k - 1, n - k) + 2 * n + 1
else:
    ans = 3 * n
print(ans)


n, k = list(map(int, input().split()))
ans = (n + 1) + n + min(n - k, k - 1) + (n - 1)
print(ans)


n, k = list(map(int, input().split()))

l = k - 1
r = n - k

print(1 + n + 2 * min(l, r) + max(l, r) + n)


n, k = map(int, input().split())
if 2 * k <= (n + 1):
    print(3 * n + k - 1)
else:
    print(4 * n - k)

n, k = list(map( int, input().split()))

mn = min( k - 1, n - k )

print( 3*n + mn )


n,k=map(int,input().split())
ans=n*3
u=min(n-k,k-1)
ans=ans+u
print(ans)

n, k = (int(t) for t in input().split(' '))
print(n*3 + min(k-1, (n-k)))

n, k = list(map(int, input().split()))
print(n + 1 + n + n - 1 + min(k - 1, n - k))


n, m = list(map(int,input().split()))
print(n * 3 + min(m - 1, n - m))


def main():
    n,k = list(map(int,input().split()))
    moves = 2*n
    moves += 1
    moves += min(k-1,n-k)
    moves += n-1

    print (moves)

main()


n,k = list(map(int,input().split()))
if k > n//2:
	k = n + 1 - k
print( 2 * (k - 1) + 1 + k + 2 + 2 * (n - k - 1 ) + n)