n = int(input()) binary = bin(n)[2:] product = 1 for c in binary: product *= (int(c) + 1) print((n + 1) - product)