module Main where

import Control.Applicative
import Control.Monad
import Data.List

f k ms = foldr g 1 ms
  where
    g 'a' acc = acc * 2
    g 'b' acc = acc + k

main :: IO ()
main = do
    n <- readLn
    k <- readLn
    let ps = sequence $ replicate n "ab"
    let ans = minimum $ fmap (f k) ps
    print ans