inp1 = input() inp1 = int(inp1) def make_dis(eng): mass = list(bin(eng)) count = 0 for s in mass: if s == "1": count = count + 1 return count now = 1 count = 1 bad = 0 while now <= inp1: dis = make_dis(now) now = now + dis if now == inp1: count = count + 1 break elif now > inp1: now = now - dis - dis bad = bad + 1 if bad > 10: count = -1 break count = count + 1 print(count)