x = int(input()) n = 2*x - 1 ans = "" while n> 1 : ans = str(n%2) + ans n = n // 2 y = str(n) + ans print(y.count('1'))