n = int(input()) print(n - pow(2, bin(n)[2:].count("1")) + 1)