n = int(input()) if n == 1: print(0) exit() x = 1 ans = 0 while x < n: x *= 2 ans += 1 ans += x-n print(ans)