import math n = int(input()) p = math.ceil(math.log2(n)) print(p+str(bin(2**p-n)).count("1"))