N = int(input()) P = N.bit_count() ans = 2**P - 2 print(ans)