N = int(input()) def step(num,k=0,result=0): while 2**k <= num: k = k + 1 while k != -1: if 2**k <= num: num = num -2**k result = result + 1 k = k-1 return result square, prev = [1], [-1] def start(): global square, prev head, tail = 0, 1 while head < tail: now = square[head] s = step(now) if now-s > 0: if now-s not in square: square.append(now-s) prev.append(head) tail = tail + 1 if now+s <= N: if now+s not in square: square.append(now+s) prev.append(head) tail = tail + 1 if now+s == N: return True head = head + 1 return False def root(result=1): global square, prev k = prev[-1] while k != -1: result = result + 1 k = prev[k] print(result) if start(): root() else: print(-1)