import sys read = sys.stdin.buffer.read readline = sys.stdin.buffer.readline readlines = sys.stdin.buffer.readlines sys.setrecursionlimit(10 ** 7) n = int(read()) ans = 1 def check(k): global ans v = bin(k).count('1') ans += 1 if ans > 2 * n: ans = -1 elif k + v < n: check(k + v) elif k + v > n: check(k - v) check(1) print(ans)