N = int(input()) ans = 1 for i in range(62): if N >> i & 1: ans *= 2 print(ans - 2)