N = int(input()) cnt = 0 while N: cnt += N % 2 N >>= 1 print(2**cnt - 2)