n = int(input()) odd = list(map(str,bin(n))) odd_num = odd.count("1") print( n + 1 - 2**(odd_num))