h,a = map(int,input().split()) s = 1 k = h//a while not k==0: k = k//a s += 1 p = 2**(s)-1 print(p)