n=int(input()) a=n sum=n half=2*(n//2) while n!=0: sum+=n//2 n//=2 print(max(sum-(half+a),half+a-sum))