package main

/*
     o
    o o
   o o o
  o o o o
 o o o o o
o o o o o o
*/

import (
        "bufio"
        "fmt"
        "os"
        "strconv"
        "strings"
        //      "time"
)

func makePyramid(n int) [][]int {
        p := make([][]int, n+1)
        for i := 0; i < n+1; i++ {
                p[i] = make([]int, n*2+1)
        }

        for y := 0; y < n+1; y++ {
                p[y][n-y] = '/'
                p[y][n+y] = '\\'
        }
        for x := 0; x < n+1; x++ {
                p[n][n-x] = '-'
                p[n][n+x] = '-'
        }
          return p
}

func dumpPyramid(p [][]int) {
        for y := 0; y < len(p); y++ {
                for x := 0; x < len(p[y]); x++ {
                        c := p[y][x]
                        if c == 0 {
                                fmt.Print(" ")
                        } else {
                                fmt.Printf("%c", p[y][x])
                        }
                }
                fmt.Println("")
        }
}

func readIntArray(bio *bufio.Reader) []int {
        s, _ := bio.ReadString('\n')
        valsStr := strings.Split(strings.Trim(s, "\n"), " ")
        vals := []int{}
        for _, s := range valsStr {
                val, _ := strconv.Atoi(s)
                vals = append(vals, val)
        }
        return vals
}

type Pos struct {
        x int
        y int
}

type Dir struct {
        dx int
        dy int
}

func proceed(pos Pos, dir Dir, p [][]int) (Pos, Dir) {
        nextPos := Pos{pos.x + dir.dx, pos.y + dir.dy}
        if p[nextPos.y][nextPos.x] == 0 {
                switch {
                case dir.dx == -2 || dir.dx == 2:
                        p[nextPos.y][nextPos.x] = '-'
                case dir.dx == dir.dy:
                        p[nextPos.y][nextPos.x] = '\\'
                default:
                        p[nextPos.y][nextPos.x] = '/'
                }
        } else {
                switch p[nextPos.y][nextPos.x] {
                case '-':
                        dir.dy = -dir.dy
                case '/':
                        if dir.dx == -2 {
                                dir.dx = 1
                                dir.dy = 1
                        } else if dir.dx == 2 {
                                dir.dx = -1
                                dir.dy = -1
                        } else if dir.dx == -1 {
                                dir.dx = 2
                                dir.dy = 0
                        } else {
                                dir.dx = -2
                                dir.dy = 0
                                                 }
                case '\\':
                        if dir.dx == -2 {
                                dir.dx = 1
                                dir.dy = -1
                        } else if dir.dx == 2 {
                                dir.dx = -1
                                dir.dy = 1
                        } else if dir.dx == -1 {
                                dir.dx = 2
                                dir.dy = 0
                        } else {
                                dir.dx = -2
                                dir.dy = 0
                        }
                default:
                        panic("unknown")
                }
        }
        return nextPos, dir

}

func solve(n int, x int) int {
        p := makePyramid(n)
        //dumpPyramid(p)

        startPos := Pos{n - x, x}
        curPos := startPos
        curDir := Dir{2, 0}
        length := 0
        for {
                        //fmt.Printf("pos=%v, dir=%v\n", curPos, curDir)
                nextPos, nextDir := proceed(curPos, curDir, p)
                length++
                if startPos == nextPos {
                        break
                }
                curPos = nextPos
                curDir = nextDir
                //dumpPyramid(p)
                //time.Sleep(1 * time.Second)
        }

        return length
}

func main() {

        bio := bufio.NewReader(os.Stdin)
        vals := readIntArray(bio)
        fmt.Printf("%v\n", solve(vals[0], vals[1]))
}
