def hanoi(x): if x == 1: return 1 return hanoi(x-1)*2+1 n, l = map(int, input().split()) m = n//l if n%l == 0 else n//l+1 print(hanoi(m))