import math H, A = list(map(int, input().split())) depth = 0 while H >=1: H //= A depth += 1 # print(depth) ans = pow(2, depth-1) + 1 print(ans)