N = int(input()) i = 1 count = 1 judge = True def go(m): a = m b = m move = 0 a2 = bin(m) move = a2.count("1") if b + move <= N: b += move else: b -= move return b j = [] while i != N: j.insert(0,i) i = go(i) count += 1 if i in j: judge = False break if judge == True: print(count) elif judge == False: print(-1)