n = int(raw_input()) print n + 1 - 2 ** (bin(n).count("1"))