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