'use strict'
const inputs = require('fs').readFileSync(0, 'utf8').split('\n')
const N = parseInt(inputs[0], 10)
const K = parseInt(inputs[1], 10)
if (N === 1) console.log(2)
else if (K === 1) console.log(1+N)
else if (K === 2) console.log(2+2*(N-1))
else if (N === 2) console.log(4)
else if (K <= 4) console.log(4+K*(N-2))
else if (N === 3) console.log(8)
else if (K <= 8) console.log(8+K*(N-3))
else console.log(16+K*(N-4))