def main(): N = int(input()) route = list(range(1, N + 1)) current = 0 moved = 1 over = 0 while route[current] != N: step = get_step(route[current]) if current + step < len(route): current += step else: current -= step over += 1 if over > 1: moved = -1 break moved += 1 print(moved) def get_step(value): step = 0 while value > 0: if (value & 1) == 1: step += 1 value >>= 1 return step if __name__ == '__main__': main()