N = int(input()) if N == 1: print(0) else: n = bin(N).count("1") print(pow(2, n) - 2)