You are a lover of bacteria. You want to raise some bacteria in a box. 

Initially, the box is empty. Each morning, you can put any number of bacteria into the box. And each night, every bacterium in the box will split into two bacteria. You hope to see exactly *x* bacteria in the box at some moment. 

What is the minimum number of bacteria you need to put into the box across those days?
The only line containing one integer *x* (1 ≤ *x* ≤ 10<sup class="upper-index">9</sup>).
"""
    Code's Noob Coder 
    Từ Trường THPT Nguyễn Công Trứ
    Từ Trường Đại học Bách Khoa - Đại học Quốc Gia TPHCM
"""

import itertools,sys
from operator import truediv
import math
INT_MAX = 9223372036854775807 
INT_MIN = -9223372036854775807 
MOD = 1e9 + 7

"""
    Algorithm 
"""

##################### memset #####################
def memset(a,Value,Size):
    a[:] = bytearray(Size)
    a[:] = itertools.repeat(Value,len(a))
    return a

##################### Kadane Algorithm #####################
def Kadane_Algorithm(a):
    max_so_far = INT_MIN
    max_ending_here = 0
    for i in a:
        max_ending_here += i
        max_so_far = max(max_ending_here,max_so_far)
        max_ending_here = max(max_ending_here,0)
    return max_so_far

##################### Sieve of Eratosthenes #####################
List_of_Prime_Number = []
lpf = []
def Sieve_of_Eratosthenes(n):
    memset(List_of_Prime_Number,2,1)
    memset(lpf,2,n+1)
    x = 3
    while x <= n:
        if lpf[x] == 2:
            List_of_Prime_Number.append(x)
            lpf[x]=x
        i = 0
        while i < len(List_of_Prime_Number) and List_of_Prime_Number[i] <= lpf[x] and List_of_Prime_Number[i] * x <= n:
            lpf[List_of_Prime_Number[i]*x] = List_of_Prime_Number[i]
            i += 1
        x += 2

"""
    Data Structers
"""

##################### Fenwick Tree #####################
class Fenwick_Tree(object):
    bit = []
    def init(n):
        memset(Fenwick_Tree.bit,0,n+1)
    
    def Update_Point(i,v,n):
        idx = i
        while idx <= n:
            Fenwick_Tree.bit[idx] += v;
            idx += idx&(-idx)

    def Update_Range(l,r,v,n):
        Fenwick_Tree.Update_Point(l,v,n)
        Fenwick_Tree.Update_Point(r+1,-v,n)

    def Get_ai(r,n):
        idx = r
        res = 0
        while idx > 0:
            res += Fenwick_Tree.bit[idx]
            idx -= idx&(-idx)
        return res

##################### Segment Tree #####################
class Segment_Tree(object):
    tree = []
    def init(n):
        Size = 1
        while Size < n:
            Size *= 2
        memset(Segment_Tree.tree,0,Size*2)
        return Size
    
    def build(i,v,x,lx,rx):
        if lx + 1 == rx:
            Segment_Tree.tree[x] = v
            return
        mid = (lx + rx)/2
        if i < mid:
            Segment_Tree.build(i,v,2*x+1,lx,mid)
        else:
            Segment_Tree.build(i,v,2*x+2,mid,rx)
        Segment_Tree.tree[x] = max(Segment_Tree.tree[2*x+1], Segment_Tree.tree[2*x+2])

    def Query(l,r,x,lx,rx):
        if l >= rx or r <= lx:
            return INT_MIN
        if l <= lx and rx <= r:
            return Segment_Tree.tree[x]
        mid = (lx + rx)/2
        return max(Segment_Tree.Query(l,r,2*x+1,lx,mid), Segment_Tree.Query(l,r,2*x+2,mid,rx))

##################### Giải bài #####################

x = int(input())
temp = x

while True:
    if temp - (temp & (-temp) ) == 0:
        break
    else:
        temp-=temp&(-temp)

print(1 + x - temp)