N = int(input()) B = format(N, 'b') cnt = 0 while B != '1': if B[-1]=='0': cnt+=1 B = format(int(B, base=2)//2, 'b') else: cnt+=2 B = format((int(B, base=2)+1)//2, 'b') print(cnt)