n=int(input()) c=n.bit_count() print((2**c)-2)