def main(): inp1 = int(input()) count = 1 num = 1 loop_flg = True maxi = 0 while loop_flg: if maxi < num: maxi = num if num == inp1: break elif num > inp1: num = num - (bins * 2) else: pass bins = int(bin(num).count("1")) num = bins + num count += 1 if maxi == num: count = -1 break if inp1 == 1: count = 1 print(count) if __name__ == '__main__': main()